I am looking for a code sample that inserts an image in a Sql Server database and a separate routine that extracts it from the database and displays it. My best guess is that this needs to be done with a byte array, but historically my guesses have a poor track record.
Do you have a code sample in VB6?
Insert Image into SQL Server
Re: Insert Image into SQL Server
The following code works with MS-Access and hopefully should work with SQL Server too. Here, rsimg is the recordset having the image stored in an "OLE Object" type column "docimage".
Code: Select all
'---read image from database
Dim arbyte() as byte
arbyte = rsimg.Fields("docimage").GetChunk(LenB(rsimg.Fields("docimage"))) 'get image & store in byte
GdViewer1.DisplayFromByteArray (arbyte()) 'display image in viewer
Erase arbyte
rsimg.Close
'---insert image into database
Call Imaging1.SaveAsByteArray(arbyte, 0, "tif") 'save scanned image into byte
With rsimg 'recordset
.AddNew
.Fields("docimage").AppendChunk (arbyte())
.Update
MsgBox "Page Saved"
End With
-
- Posts: 1
- Joined: Sat Nov 28, 2015 8:10 am
Who is online
Users browsing this forum: No registered users and 1 guest