Character set 'utf8mb4' is not supported in .Net Framework MySql.Data.dll

Recently, I was working in .Net framework and MySQL database. Below procedure was throwing error "character set 'utf8mb4' is not supported" while I called it .Net framework. However, It was running successfully in command prompt.

DELIMITER $$
CREATE PROCEDURE GetAllProducts()
BEGIN
    SELECT
        productName,
        productCode,
        quantity,
        addedDate,
        1 as inStock
    FROM
        products
    ORDER BY productName;    
END$$
DELIMITER ;

Unfortunately, I didn't land on the appropriate result by googling. So, I tried to isolate the issue by rewriting the query and found that as soon as I remove the "1 as inStock" part, my error was solved. However, I was badly needed the "1 as inStock" part. So, I rewrite the procedure:

DELIMITER $$
CREATE PROCEDURE GetAllProducts()
BEGIN

       DECLARE instock1 VARCHAR(5);

    SET instock1 = 1;
    SELECT
        productName,
        productCode,
        quantity,
        addedDate,
        instock1 as inStock
    FROM
        products
    ORDER BY productName;    
END$$
DELIMITER ;

This solves my  "character set 'utf8mb4' is not supported" error!

Add comment