views:

584

answers:

1

I'm using a SQLite database to store cover images of books I have in a database. I've got the inserting of BLOBs ok, but when I don't have a cover image for my book I can't seem to get it to insert a null BLOB.

I'm using parameters for my insert SQL statement, using ODBC, as shown below:

OdbcParameter^ paramCoverImage = gcnew OdbcParameter("@CoverImage", ByteArray);

cmd->Parameters->Add(paramCoverImage);

But when I try and do it with nullptr instead of the ByteArray, SQLite gives an error. I want to use the SQL NULL, but I can't find out how to do that using ODBC and SQLite. Any ideas?

Robin

+2  A: 

Try:

OdbcParameter^ paramCoverImage = gcnew OdbcParameter("@CoverImage", OdbcType::Binary);
paramCoverImage->Value = System::DbNull->Value;
Reed Copsey
That worked perfectly. Thank you. :-)
robintw