CAST to binary not working

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
qnguyen
Posts: 2
Joined: Thu 25 Aug 2005 16:28
Location: Houston

CAST to binary not working

Post by qnguyen » Thu 25 Aug 2005 16:35

I have a tinyblob column that I want to insert binary data into it( a guid)

I create a MySqlCommand using parameter is follow

INSERT INTO MY_TABLE (IDCol) Values (CAST(0xCE2A0AA8D33211D79C4800A0CC40804D AS BINARY))

but when I look in the table, the data is just insert as text

0xCE2A0AA8D33211D79C4800A0CC40804D

Anyone know how to make it insert as binary?

Thanks.

qnguyen
Posts: 2
Joined: Thu 25 Aug 2005 16:28
Location: Houston

Post by qnguyen » Thu 25 Aug 2005 18:15

look like the driver put single quote around my value
because the parameter type is default to varchar.

'0xCE2A0AA8D33211D79C4800A0CC40804D'

Is there a way to tell it to not put single quote around the value?

thanks.

Serious

Post by Serious » Fri 26 Aug 2005 06:42

You have to use parameters.

Code: Select all

MySqlCommand command = new MySqlCommand("insert into my_table(f_tinyblob) values (:blob)", connection);

byte [] data;
...
command.Parameters.Add("blob", data);
command.ExecuteNonQuery();

Post Reply