dears, I'm successfully save image to SQL DB and try to retrieve it but with error message as follow:
( Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another) and highlight on red code below. Please any advice to get it solved? Thank you in advance.
below code i used to save image to DB:
Also, below code i used to load image from DB:
( Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another) and highlight on red code below. Please any advice to get it solved? Thank you in advance.
below code i used to save image to DB:
Code:
Private Sub SavePic2SQLDB(ByRef tempRS As ADODb.Recordset)
Dim iFileNum As Integer
Dim lFileLength As Long
Dim abBytes() As Byte
Dim sTempFile As String
sTempFile = txtPixPath.Text
'read file contents to byte array
iFileNum = FreeFile
Open sTempFile For Binary Access Read As #iFileNum
lFileLength = LOF(iFileNum)
ReDim abBytes(lFileLength)
Get #iFileNum, , abBytes()
'put byte array contents into db field
tempRS.Fields("Image").AppendChunk abBytes()
Close #iFileNum
End Sub
Code:
Private Sub LoadPicFromSQLDB(ByRef tempRS As ADODb.Recordset)
Dim iFileNum As Integer
Dim iFileLength As Long
Dim abBytes() As Byte
Dim sTempFile As String
Dim rsReceived As ADODb.Recordset
sTempFile = App.path & "\pix\" & Format(Now, "yyyymmddhhnnss") & ".jpg"
iFileNum = FreeFile
Open sTempFile For Binary As #iFileNum
iFileLength = LenB(tempRS("Image"))
ReDim abBytes(iFileLength)
abBytes = tempRS("Image").GetChunk(iFileLength)
Put #iFileNum, , abBytes()
Close #iFileNum
If Not sTempFile = "" Then
Set curPicture = LoadPicture(sTempFile)
If Not curPicture Is Nothing Then
Image1.Picture = curPicture
End If
End If
'=== delete the temp file away ====
Kill sTempFile
End Sub