Hi,
I am using SQL Server 2005. I have a table in my database which has two columns :
ImageId (Type: nvarchar (50))
Image (Type: image)
I need to store images in this table. How can I do this?
Depends on what do you use for writing client applications.|||Example using VB 6.0, SQL Server 2005 and SQLNCLI as the provider.
Private Sub Main()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim mystream As New ADODB.Stream
cn.CursorLocation = adUseClient
cn.Open "Provider=SQLNCLI;Data Source=.;Integrated Security=SSPI;"
mystream.Type = adTypeBinary
rs.Open "select * from imagetable where imagetable.ImageId=''", cn, adOpenStatic, adLockOptimistic
rs.AddNew
mystream.Open
mystream.LoadFromFile "c:\\test.jpg"
rs!ImageId = "image1"
rs!MyImage = mystream.Read
rs.Update
mystream.Close
rs.Close
cn.Close
End Sub
No comments:
Post a Comment