ImageBLOBs and VB via ODBC
Posted in 1993
Topics: Storage & Space Management, Stored Procedures & SPL, Connectivity: ODBC / JDBC / .NET, Networking & sqlhosts Configuration
( In response to David Huang's Letter 'stevehsu@tpovc.enet.dec.com' ) > I tried to use "loadpicture" API in Visual Basic 3.0 and Q+E ODBC Informix > driver to insert/select image file into/from remote Informix Online server. > But, I got error message "It's illegal operation,...". Anyone got any > idea how to manipulate image (BLOB/Bytes) data in a client/server environment. > The PC site has Visual Basic 3.0, Q+E ODBC Pack, Informix-Net PC, TCP/IP. > The UNIX server site has Informix Online, Star, SQL. At my place of work we have exactly the same setup. What we wanted to do was to fetch J-PEG pictures from a BLOB column in the database and display them. To get the pictures into the database in the first place we used J. Lefflers 'updblob' utility. (Thanks) We found no way to get the binary data straight from the database and into the picture control. Using the Data control with the Picture control and linking them together with the 'Data aware' properties works only for .BMP, .ICO and .WMF formats, the only formats the Picture control supports. We are using another Picture control from Accusoft that supports 'Any' picture format, but can not read the J-PEG data straight from the database through the data control and display it. The reason was something about the Data control not recognising (or was it supporting) pure binary data. Displaying .BMP .ICO or .WMF formats was no problem with this picture control either. In the end what we had to do was create a dynaset to fetch the J-PEG Picture in the BLOB column, write it down to a temporary disk file and reading it again from disk to display it. We use this method to fetch BLOB's up to 20K in size, and it isn't that slow. Sub Opendb () Set db = OpenDatabase("", False, False, "odbc;dsn=spar;database=spar;") End Sub Sub Command1_Click () Dim strng As String Opendb screen.MousePointer = 11 Set ds = db.CreateDynaset("select picture from pictures where key = '" & mkey & "'") If Not ds.EOF Then ds.MoveFirst strng = ds("picture") Handle = FreeFile Open app.Path & "\\pict.jpg" For Binary As Handle Put #Handle, , strng Close Handle acumynd.Image = app.Path & "\\pict.jpg" screen.MousePointer = 0 Else screen.MousePointer = 0 MsgBox ("No Picture Exists") End If ...... ...... End Sub This is an inelegant solution, but it gets the job done although it is limited to the 64K string size, but that can be bypassed with the '-Chunk' methods. Isn't it nice to have brothers in arms. I myself would like to know if anyone knows of another (preferably better) method of fetching and displaying non .BMP, .ICO, .WMF data stored as BLOB in our favorite database. A method not involving writing data to the disk. skapti@spar.is skapti@ismennt.is