ODBC and blobs
Posted: Wed Aug 11, 2010 10:33 am
Hi,
I can work with blobs with an MS Access file using ADO without a problem, but something seems afoot with ODBC!
Can anyone get the following working? (Or has anyone successfully worked with MS Access blobs using ODBC?)
You'll need to add an appropriate ODBC DSN before you can run the following. I just created an empty mdb file through the control panel when setting up the DSN. Everything works fine with basic number and text fields etc. You'll also need to use your own image (or any old file actually!)
I can work with blobs with an MS Access file using ADO without a problem, but something seems afoot with ODBC!
Can anyone get the following working? (Or has anyone successfully worked with MS Access blobs using ODBC?)
The error message reported suggests a problem with binding parameters etc.[Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
You'll need to add an appropriate ODBC DSN before you can run the following. I just created an empty mdb file through the control panel when setting up the DSN. Everything works fine with basic number and text fields etc. You'll also need to use your own image (or any old file actually!)
Code: Select all
UseODBCDatabase()
If OpenDatabase(1, "BLOBTEST", "", "", #PB_Database_ODBC)
cmd$ = "Drop Table Pictures)"
DatabaseUpdate(1, cmd$)
cmd$ = "Create Table Pictures(Picture LONGBINARY)"
DatabaseUpdate(1, cmd$)
;Insert some data.
SetDatabaseBlob(1, 0, ?pic1, ?endPic1 - ?pic1)
SQL$ = "Insert Into Pictures Values (?);"
DatabaseUpdate(1, SQL$)
Debug DatabaseError()
;Close database.
CloseDatabase(1)
EndIf
DataSection
pic1:
IncludeBinary "image0.bmp"
endPic1:
EndDataSection