Query to MySQL from C# returns System.Byte[]

Hello All,

I'm working on Mysql for almost a year now but yesterday I got one issue which was killing me. I wrote a Stored Procedure in MySQL and execute it in MySQL Browser and it execute very well but when I execute the same Stored Procedure in asp.net and bind the returned DataSet with GridView, it always shows System.Byte[] in the Title Column.

The problem was that the columns which I had selected in that query was having DataType as LongText and LONGTEXT type is a kind of BLOB type (set of byte), so it was returning System.Byte[].

I checked it on google, tried different ways to fix it but nothing helped me and finally I thought firing a query on it and it worked. Something like this:

SELECT
           ID
           ,TitleName
FROM (

                   SELECT
                                  ID
                                  ,REPLACE(Title, "$", "'") AS TitleName
                   FROM
                                  tbEmployee
         ) A

This it what I did and its working fine.

Hope this helps you all.

Happy Coding :)

1 comment: