all groups > sql server misc > february 2006 >
You're in the

sql server misc

group:

Please help! Insert a picture in an MS SQL Server table


Please help! Insert a picture in an MS SQL Server table De kessé
2/5/2006 10:49:53 AM
sql server misc: Please help! Insert a picture in an MS SQL Server table

How can u insert a picture an an image field in SQL server table? Is it
possible from SQL server tools or other tools, programming?


Re: Please help! Insert a picture in an MS SQL Server table Scott Cupstid
2/8/2006 1:15:05 PM
First, the column in the SQL Server table should be one of the BLOB types
(text, ntext or image). Then the best way to load the image is to use an
application. Here is a snippet that should help you...

'Initialize the stream object used to load the file.
Set st = New ADODB.stream
st.Type = adTypeText
st.Open
st.LoadFromFile ("c:\Emp9.txt")

'Write the value of the field to the stream.
rs.Fields("Notes").Value = st.ReadText
Notice the reference to "rs" That is a pointer to a record set that
contains the BLOB column. The routine instantiates an intermediary stream
object to load the image from a file into memory. The stream is then loaded
to the column by setting the Value property of the field.

The example above loads a text file, but the file could be any kind of file.
The stream simply looks for data and the column may contain any binary data.
Whatever uses the data in the column will have to be able to interpret the
data.

[quoted text, click to view]

AddThis Social Bookmark Button