If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > ADODB.Stream and Byte2Hex conversion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-16-03, 12:35
ms_sql_dba ms_sql_dba is offline
Registered User
 
Join Date: Sep 2003
Posts: 522
ADODB.Stream and Byte2Hex conversion

i am trying to use ADODB.Stream object to read an image file into a byte array. then i want to take that byte array and convert it to a hex value and pass it to a SQL Server stored procedure that takes it as a parameter and writes it to an IMAGE field in a table.

here's what I have so far:

Code:
Private Sub Form_Load()
   Dim adoStream As ADODB.Stream, _
       con As ADODB.Connection, _
       rs As ADODB.Recordset, _
       o() As Byte
   Set adoStream = New ADODB.Stream
   adoStream.Open
   adoStream.Type = adTypeBinary
   adoStream.LoadFromFile "c:\tmp\test.bmp"
   Set con = New ADODB.Connection
   con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=TEST1;Data Source=L6064909"
   o = adoStream.Read
   con.Execute ("exec sp_AddImage " & Byte2Hex(o))
End Sub
the problem is with Byte2Hex function. there i have to loop through every element of the o() and use a Hex() function on each. i guess the question is: can i convert my byte array to hex in one shot, without converting each element?

a secondary question is: is there a better way of doing this? i really don't want to use rs.AddNew...rs.Update

i tried to bypass storing the image to the byte array and just call Read method at the time of executing the sp, but vb complained about the question marks.

any thoughts, suggestions?

thanks in advance.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On