|
-
Jan 5th, 2011, 04:01 PM
#1
Thread Starter
New Member
Problem saving image from vb6 to Sql 2000 with RhinoBull Procedure
Hi!.. this is the thread then
The initial problem I had was finally solved. The problem what that I created my Recordset as Readonly
Now the procedure ends correctly, but the data is not saved to the db column
This is the procedure as it is now
Code:
Public Function AddNewImage(rstTemp As ADODB.Recordset, _
id As String, sFileName As String) As Boolean
'=============================================================
Dim file_num As String
Dim file_length As Long
Dim bytes() As Byte
Dim num_blocks As Long
Dim left_over As Long
Dim block_num As Long
On Error GoTo ErrHandler
AddNewImage = False
'I decided to use a Filter in order to find the record I need to update
rstTemp.Filter = " id_Chofer = " & Cmb_Chofer.Text & ""
file_num = FreeFile
Open sFileName For Binary Access Read As #file_num
file_length = LOF(file_num)
If file_length > 0 Then
'I defined a BLOCK_SIZE constant of 250000 since my files will always be not more de 220000
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE
'Not using this, so no need to save it to the recordset or the db
'rstTemp("fImageSize") = file_length
ReDim bytes(BLOCK_SIZE)
For block_num = 1 To num_blocks
Get #file_num, , bytes()
'The field name where I want to save the image data is BioID
rstTemp("BioID").AppendChunk bytes()
Next block_num
If left_over > 0 Then
ReDim bytes(left_over)
Get #file_num, , bytes()
rstTemp("BioID").AppendChunk bytes()
End If
Close #file_num
End If
'update RS
rstTemp.Update
'Remove Filter
rstTemp.Filter = ""
AddNewImage = True
Exit Function
ErrHandler:
Debug.Print Err.Description
Err.Clear
'Resume Next
Exit Function
End Function
Why is this not updating my table's column? It is defined as IMAGE
Thanks
-
Jan 5th, 2011, 05:07 PM
#2
Re: Problem saving image from vb6 to Sql 2000 with RhinoBull Procedure
It's difficult to suggest anything without knowing how fields are defined, etc info...
Why do you filter? Why not populating recordset object with just one record based on that id_Chofer instead?
What happens when rstTemp.Update is executed? Does it go to the next line or directly to error handler?
So, it's not the problem with what I posted long time ago but rather with what you have at the moment so you may re-title your thread.
-
Jan 6th, 2011, 06:44 AM
#3
Thread Starter
New Member
Re: Problem saving image from vb6 to Sql 2000 with RhinoBull Procedure
Hi, and thanks for your reply.
I will try to detail the whole scenario so you can understand what I am trying to do.
I have this little problem that connects to a fingerprint scanner and updates our Employees table. When I want to add a fingerprint to an existing employee, I first select the employee's id from a combobox (created using a Recordset that contains all the "employees" table data).
Then I scan the fingerprint, and save the image to disk (bmp_[employee_id].bmp)
Then I want to use that bmp file to save it to the database, in the BioID column corresponding to the selected employee.
So that is why I filter the recordset, with the selected ID from the combobox.
The BioID column is set as IMAGE in the database
When the rstTemp.Update is executed all goes fine, no error triggered, but then I check the record in the database, and it is still null.
Maybe the error has to do with the way I create the Recordset. How exactly do I need to define it in order to keep it connected to the database, and allow it to update the table upon rstTemp.update method?
Thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|