Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Inserting pictures using VB 6.0

Posted on 2003-10-23
8
Medium Priority
?
1,529 Views
Last Modified: 2010-07-27
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.
0
Comment
Question by:miteshn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 18

Accepted Solution

by:
BigSchmuh earned 2000 total points
ID: 9632359
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 http://www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/v7pubs.d2w/en_main

Hope this helps.
0
 

Author Comment

by:miteshn
ID: 9635124
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.
Thanks,
Mitesh



0
 
LVL 18

Expert Comment

by:BigSchmuh
ID: 9640264
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
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 18

Expert Comment

by:BigSchmuh
ID: 9640272
(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.
0
 

Author Comment

by:miteshn
ID: 9642744
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.
Thanks,
Mitesh
0
 
LVL 18

Expert Comment

by:BigSchmuh
ID: 9644718
The API can be found in the "Call Level Interface Guide and Reference" at http://www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/v7pubs.d2w/en_main
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.
0
 
LVL 2

Expert Comment

by:ScottNewman
ID: 9749033
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!!
Newman
0
 
LVL 2

Expert Comment

by:ScottNewman
ID: 9749044
oops, me soo stupid.  Didn't see it was answered (still getting used to the new format).

Ignore my post.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question