While working on one of the project's i came across a scenario when data text field i binded in radio button list showed data on local but online it showed System.Byte[] instead of text.I was using Mysql database and for data text field i was concatenating 3 values .When i run that query on mysql it returned me data.I got expected results while running on local but when same code was deployed on server an unexpected thing occur.
After lot of investigation and goggling i found one interesting thing that it was not the problem with code,it was merely a mysql .NET connector, version 5.1.6.Actually on local i was having .NET connector, version 3.51
According to mysql.com it is not a bug ,but it is expected behaviour.According to mysql.com if we are having any query that concatenates two or more columns ,Then one of the scenario will occur:-
mysql> SELECT CONCAT("Tonci", " ", "Grgin") AS Name;
Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string.
mysql> SELECT CONCAT("Tonci ", 1, " Grgin") AS Name;
BINARY flag is set (this is where your problem is!)
This will return binary string.
Now here is the solution to the problem:
Cast the result of concatenate query as Char and then use it.Hence the issue of System.Byte array in Data Text Field will be solved.
mysql> SELECT CAST(CONCAT("Tonci ", 1, " Grgin") AS CHAR) AS Name;
For further details Visit:http://bugs.mysql.com/bug.php?id=37485
Showing posts with label Mysql. Show all posts
Showing posts with label Mysql. Show all posts
Wednesday, April 17, 2013
Monday, March 25, 2013
Cyrillic(Russian ) characters not displaying in asp.net using mysql 3.5.1
When we are using .net with mysql many a times we face a problem that cyrillic(russian)or any other language characters dont display on page or console as expexted .Instead we get ???.The solution to this problem is that we might be using mysql connector driver that does not support cyrillic characters.I was using mysql connector 3.5.1 and faced the same problem.After lot of googling i didn't get any result.So i changed my mysql connector driver from 3.5.1 to 5.1.12 and it worked . The reason for this is MySQL does not support the full UTF8 character set, 4-byte characters are not allowed.
MYsql 3.5.1 connector does not support all UTF_8 Characters.
Also i changed my connection string as
{Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;}
Monday, January 28, 2013
Get all rows for paticular column in one column.
For getting records returned by a sql query in one column comma seperated we can use
SELECT GROUP_CONCAT(columnname) AS columnname FROM tablename WHERE condition .
This query will return all query results for paticular column in one column comma seperated.
Thursday, November 29, 2012
How to take backup of database using mysql command line
Taking backup from mysql command Line is quite simple .Just follow following steps and its done.
1)Open command prompt(run as administrator).
2)Move to the bin directory of mysql server.
3) Type following command
mysqldump -u root -p [your password] [database name for backup] -r ["filename"]
4)Dont forget to add double quotes for file name.
Note:If you dont specify path of file ,then it will go in default directory(Programfiles\Mysql\mysqlserver5.\bin).
1)Open command prompt(run as administrator).
2)Move to the bin directory of mysql server.
3) Type following command
mysqldump -u root -p [your password] [database name for backup] -r ["filename"]
4)Dont forget to add double quotes for file name.
Note:If you dont specify path of file ,then it will go in default directory(Programfiles\Mysql\mysqlserver5.\bin).
Subscribe to:
Posts
(
Atom
)