Inserting pictures using VB 6.0

I want to insert pictures into a table using VB. I have defined it as a BLOB datatype. I could not find any way to insert the pictures using SQL statements through VB. Any sample code or reference to documentation would be great.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Whatever the DBMS, using BLOB is usually not accessible using simple SQL except if you use size restricted BLOB.
There are specific APIs to manipulate BLOB in DB2:
SQLBindFileToCol() Associates LOB file reference with a LOB column.
SQLBindFileToParam() Associates LOB file reference with a parameter marker.
SQLGetLength() Gets length of a string referenced by a LOB locator.
SQLGetPosition() Gets the position of a string within a source string referenced by a LOB locator.
SQLGetSubString() Creates a new LOB locator that references a substring within a
source string (the source string is also represented by a LOB locator).

==> Those APIs may be better understood if you are familiar with ODBC API programming and the good manual is available as "Call Level Interface Guide and Reference" at

Hope this helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
miteshnAuthor Commented:
Hi BigSchmuh,
Let me refine my question a bit. I was using IBM ODBC Driver which comes with DB2. I am getting the following error message on using IBM ODBC Driver: -

Run-Time error '3251':

Current RecordSet does not support updating. This may be a limitation of the provider, or of the selected lock type.

I do not know how to proceed with the inserting now. There is not a lot of documentation available online. Any pointers to a good sourec would be great.

I am not sure I understand you well.
I do not think you can define a RecordSet to access your BLOB data but need to use the API from my first post (If you are familiar with calling Windows API, those may be very easy to gzet working)

Regarding a SELECT on table with no BLOB columns
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

(continued) you must define a Primary key on your table and retrieve every columns included in your primary key for your Recordset to be updatable.
==> I know you can update DB2 tables using RecordSet because I was able to do this using basic query in MS-Access

Hope this helps.
miteshnAuthor Commented:
Hi BigSchmuh,
Where do I find the API's that you mentioned? Can I use those API's from VB6.0? Also, any code sample using these API's through VB would be great.
The API can be found in the "Call Level Interface Guide and Reference" at
but I can not provide you with VBA examples as they are more commonly used in C.

I think you can try to call those API if you are familiar of calling Windows API from VB.
==> Be aware that improperly calling an API (for example providing wrong parameter type or value) may crash your application ("Memory can not be read" or other GPF error)

Hope this helps.
Your problem is not in your code, it's in db2 itself.  Your problem lies in the fact that the db2 tables you are trying to access are not journaled, and hence you cannot update, insert or delete from them.  (Has to do with the transaction levels)  Ask your db2 admin to journal these files, and you will then be able to insert and update them.  Otherwise, all you can do is select from them.  

Hope that helps!!
oops, me soo stupid.  Didn't see it was answered (still getting used to the new format).

Ignore my post.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.