Problem with ODBC and Binary Large Object in VB 5.0
Posted in 1998
Topics: Storage & Space Management, Stored Procedures & SPL, Connectivity: ODBC / JDBC / .NET, Migration, Import/Export & Data Conversion
This is a multi-part message in MIME format. --------------952A6694D02322D2CA01698E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello, I want to get images out of an Informix Database and display them in my Visual Basic program. I use ODBC to connect to the Database. The table in the DB has the following structur: blobtest image_id serial primary key image_name text image_data byte I don't have problems to conect to the DB or to recieve image_id or image_name. I can also get the image_data and put it into a array of bytes, but the program crashes randomly. If it crashes, it crashes when I try to get the image_data (blob). Sometimes it crashes just after the first picture. Sometimes I can recive more than ten Images until it crashes. I get an error like: The Insturction in "0x77f....." points to memory in "0x0000000030". "read" can cont be performed on memory. I tryed to dynamicaly allocate the memory used for the blob by getting .FileSize but it diden't help. Also getting the blob in Chunks did not help. I use Windows NT 4.0 Workstation SP3, VB 5.0 Ent. edt. SP3, INTERSOLV/Informix ODBC Driver Version 3.00.0005 and Informix Connect 7.2 Has someone the same Problems or does someone know what I am doing False? Are there other ODBC-Drivers than the Intersolv? Any Help would be great. Thanx Patrick Dittrich Akros AG Here is the code: Dim Ws As Workspace Dim conn As Connection Dim data_set As Recordset Dim fromstartup As Boolean Dim chunk, fsize, x As Long Dim char As Byte Option Explicit Public Sub Update() Dim bild() As Byte Text1.Text = data_set.Fields("image_id") Text2.Text = data_set.Fields("image_name") 'fsize = data_set.Fields("image_data").FieldSize 'Label7.Caption = fsize 'ReDim bild(fsize) As Byte Open "c:\\tempfile.tif" For Binary Access Write As #1 Close #1 Kill "c:\\tempfile.tif" Open "c:\\tempfile.tif" For Binary Access Write As #1 'For chunk = 0 To fsize Step 1000 bild = data_set.Fields("image_data") '.GetChunk(chunk, 1000) Put #1, , bild 'Next chunk Close #1 Gear1.DebugLevel = 1 Gear1.LoadImage = "c:\\tempfile.tif" 'Just to show the Image End Sub Private Sub Form_Load() fromstartup = True Set Ws = CreateWorkspace("ODBCTest", "", "", dbUseODBC) Workspaces.Append Ws Set conn = Ws.OpenConnection("Connection", dbDriverPrompt, True, "ODBC;") Set data_set = conn.OpenRecordset("SELECT image_id, image_name, image_data FROM blobtest", dbOpenSnapshot) HScroll1.Min = 1 HScroll1.Max = data_set.RecordCount fromstartup = False Update End Sub Private Sub Form_Unload(Cancel As Integer) End End Sub Private Sub HScroll1_Change() data_set.AbsolutePosition = HScroll1.Value - 1 If fromstartup = True Then Exit Sub Update End Sub --------------952A6694D02322D2CA01698E Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Patrick Dittrich Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Patrick Dittrich n: Dittrich;Patrick org: Akros AG adr: Lyss-Strasse 64;;;Nidau;BE;2560;Switzerland email;internet: dittrich@akros.ch title: Softwareengineer tel;work: ++41/(0)32 329 90 55 tel;fax: ++41/(0)32 329 90 35 tel;home: ++41/(0)32 365 77 49 note: Ein nettes "Hallo" an den Leser dieser Notiz x-mozilla-cpt: ;0 x-mozilla-html: TRUE version: 2.1 end: vcard --------------952A6694D02322D2CA01698E--