|
-
April 7th, 2008, 08:23 AM
#1
INSERT blob causing null error using ODBC
Hi,
I am trying to insert a blob into a MySQL database using ODBC. I am using the OdbcCommand and OdbcParameter objects as suggested on many internet sites.
My code is below:
String^ CommandText = "INSERT INTO test (Data) VALUES (@Data);";
OdbcCommand^ cmd = gcnew OdbcCommand(CommandText, conn);
array<System::Byte>^ ByteArray = gcnew array<System::Byte>(2);
ByteArray[0] = 0xFF;
ByteArray[1] = 0xFF
OdbcParameter^ param = gcnew OdbcParameter("@Data", OdbcType::Image, 2);
param->Value = ByteArray;
cmd->Parameters->Add(param);
cmd->ExecuteNonQuery();
This code always gives the error "Column 'data' cannot be null'. This is correct as the column 'data' is defined as not allowing nulls - but it presumably means that somehow the byte array is not getting through to the parameter and then the database somehow.
Does anyone have any idea what is causing this, or how I could solve it?
Any help would be much appreciated,
Robin
-
April 8th, 2008, 01:28 PM
#2
Re: INSERT blob causing null error using ODBC
From looking at this I would think that the value you are setting for you param is invalid or nothing at all. My C/C++ is a bit rusty
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|