This is a little thing, but I ran into it again today, forgot how I fixed it before, and had to figure it out again. To save myself the grief (and maybe someone else), I am posting the solution here. I had a query that worked fine when I ran it from MySql Administrator, but when I ran it in my ASP.NET application using the .NET Connector v5.2.5, I was getting System.Byte[] values.
Specifically, I had this query:
SELECT CONCAT('med: ',m.`medication_name`,', for ', c.`weight`, ' ', c.`units`,', ', c.`age`,' ', c.`case_name`) as `case_desc`
FROM `cases` c, `medications` m, `questions` q WHERE q.case_id=c.case_id AND q.medication_id=m.medication_id AND q.status=100;
It returned exactly what I wanted if I ran it in MySql Administrator. The results looked something like this:
| case_desc |
| med: Amoxicillin, for 3 kg, 1-month-old infant |
| med: Prednisone, for 3 kg, 1-month-old infant |
| med: prednisolone, for 3 kg, 1-month-old infant |
| med: Amoxicillin-Clavulanate, for 3 kg, 1-month-old infant |
| med: Keppra, for 3 kg, 1-month-old infant |
| med: Acetaminophen, for 3 kg, 1-month-old infant |
But, when I hooked this table up in my asp.net application, the page was displaying "System.Byte[]" in place of "med:Amoxicillin...etc.". I found other examples of this type of behavior reported on the mysql bug site here:
http://bugs.mysql.com/bug.php?id=26993
http://bugs.mysql.com/bug.php?id=37042
Reggie Burnett, who is the team lead at MySql for development on the .NET connector, recommends using the .GetString() method on the data reader to work around this issue. In my particular implementation, I was separating the data reader from the query (sounds weird, i know), so I went with the other suggestion, which is to add "respect binary flags=false" into my connection string which reverts back to pre 5.1 behavior and fixes the problem.