Images are really no different than any other file stored as a BLOB in a
database. The best way to put them in and take them out is through the
Stream Object (ADO 2.5 and up).
<vbcode>
Public Sub SaveFileToField(FieldName As String, FileName As String,
ConnectionString As String)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
Set cn = New Connection
cn.open ConnectionString
Set mstream = New Stream
mstream.Type = adTypeBinary
mstream.open
mstream.LoadFromFile FileName
rs.fields(FieldName).Value = mstream.read
rs.Update
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
Public Sub SaveFieldToFile(FieldName As String, FileName As String,
ConnectionString As String)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
Set cn = New Connection
cn.open ConnectionString
Set mstream = New Stream
mstream.Type = adTypeBinary
mstream.open
mstream.write rs.fields(FieldName).Value
mstream.SaveToFile FileName, adSaveCreateOverwrite
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
</vbcode>
-----Original Message-----
From: Gagandeep Singh [mailto:gagandeep77@y...]
Sent: Wednesday, April 11, 2001 6:18 AM
To: professional vb
Subject: [pro_vb] show images from a field
hi everyone
can anybody help me out. i want to create a form that
can show images from a field of sql server table the
data type of the field is image. and i dont want to
use ado data control i want it with code
thank u
please reply on gagandeep77@y...
gagan