473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to insert or update picture in db2 using vb6

1
How to insert or update picture in db2 using vb6

i have succeded to insert into text & number fileds
in the records but the Blob filed cannot be inserted
and have the following message type mismatch

and here is my code

Expand|Select|Wrap|Line Numbers
  1.    '-----------------------------------for adding a new record in pictures_file-------------------
  2.  
  3. Dim S As String
  4. Dim ne1 As Integer
  5.  
  6. Dim ne2 As Byte
  7. Dim nam As String
  8. Dim Fields(6) As String
  9. Dim values(6) As String
  10. Dim PIC_val As PictureTypeConstants
  11. Dim PIC_SAV As String
  12.  
  13. Dim PIC1_VAL As LoadPictureConstants
  14.  
  15. ne1 = Text5.Text
  16. ne2 = Text6.Text
  17. nam = Text7.Text
  18.  
  19. Fields(0) = "PIC_ID_CODE"
  20. Fields(1) = "PIC_SER"
  21. Fields(2) = "PIC_NAME"
  22. Fields(3) = "PIC_PATH"
  23. Fields(4) = "PIC_TILED"
  24. Fields(5) = "PHOTO_FORMAT"
  25. Fields(6) = "PICTURE"
  26. 'PIC_SAV = Picture
  27.  
  28.  
  29. values(0) = Text5.Text
  30. values(1) = Text6.Text
  31. values(2) = "'" & Text7.Text & "'"
  32. values(3) = "'" & Text2.Text & "'"
  33. values(4) = "'" & Text4.Text & "'"
  34. values(5) = "'" & Text3.Text & "'"
  35. PIC1_VAL = Picture2.Picture
  36. PIC_SAV = PIC1_VAL
  37.  
  38. S = ("insert into PICTURES_FILE(" & Fields(0) & "," & Fields(1) & "," & Fields(2) & "," & Fields(3) & "," & Fields(4) & "," & Fields(5) & "," & Fields(6) & " )VALUES(" & values(0) & "," & values(1) & "," & values(2) & "," & values(3) & "," & values(4) & "," & values(5) & "," & PIC1_VAL & ")")
  39.  
  40.  
  41. Dim conn As ADODB.Connection
  42.  Set conn = New ADODB.Connection
  43.  conn.ConnectionString = "Provider=ibmdadb2;Driver={IBM DB2 ODBC DRIVER};Database=ARCIV_DB;Hostname=COMPANY-C97BE4D;port=50000;Protocol=TCPIP;Uid=db2admin;Pwd=db2admin"
  44.  conn.CursorLocation = adUseClient
  45.              conn.Open
  46. conn.Execute S
  47. conn.close
Mar 19 '14 #1
1 1532
Are you sure that you are getting the error message from the Blob, or could it be something else?

The first thing I notice is that ne1 is declared as an Integer, but you are assigning a String to it. I suggest you use:
Expand|Select|Wrap|Line Numbers
  1. ne1 = Val(Text5.Text)
That should also work with ne2.

However, Values() is declared as an array of strings. So you have two choices. You can either declare ne1 and ne2 as Strings (This would be easiest.), or you can leave them as they are and use Val to assign the .Text values to them, and then use
Expand|Select|Wrap|Line Numbers
  1. Values(0) = CStr(ne1)
Either way, you are still going to have problems if the database expects Values(0) to be an Integer, but what you send it is a String.

Have you considered using a UDT (User Defined Type) instead of an array of Strings?
Apr 7 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: imani_technology | last post by:
How would I write a trigger that updates the values of a Description column to upper case for even IDs and to lower case for odd IDs? I need this trigger to fire for INSERT and UPDATE events.
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
1
by: N i E ¶ W i A D o M y | last post by:
Hello. I have a problem with insert a picture (bmp) to data base. I wan't add picture to cell in data base (Access) like double decimal. Someone have a idea how to make this? Please help ...
6
by: Patrick | last post by:
How do you insert a jpg picture from file on to an area of a dialog box I can do this using picturebox to insert a jpg picture onto a form, but the picturebox control is not available for a...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
6
by: Tom Allison | last post by:
I seemed to remember being able to do this but I can't find the docs. Can I run a sql query to insert new or update existing rows in one query? Otherwise I have to run a select query to see if...
3
by: Kunal Desale | last post by:
Hi, How to insert/update data in foxpro table field having datatype MEMO using Linked Server? I have written sql insert queries in which i have used linked server to insert data into foxpro...
4
by: lena1342 | last post by:
Hi Everyone! I tried to insert a picture in specific cells and I have coded a small VBA for Excel 2007. Unfortunately the macro only opens and inserts a picture in the active sheet but it should...
0
by: kumardharanik | last post by:
Hi Friends, The below code is a sample code for insert, update and delete using datagrid but i need to convert the entire code for datagridview.. Plsss help me.. using System; using...
7
by: ndhvu | last post by:
Tables: Buy_Header and Buy_Detail. - Buy_Header: info. of each buy (buy_id(PK, auto number), date, shop, bought_by, ...) - Buy_Detail: info. of each item from each buy (buy_detail_id(PK, auto...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.