CAST to binary not working

CAST to binary not working

Postby 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

Postby 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.
qnguyen
 
Posts: 2
Joined: Thu 25 Aug 2005 16:28
Location: Houston

Postby 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();
Serious
 


Return to dotConnect for MySQL