hi all,
i just want to know how to store photos in sql server 2000 and to retrieve it thro' vb
i just want to know how to store photos in sql server 2000 and to retrieve it thro' vb
Dim ms As New MemoryStream
Me.PictureBox1.Image.Save(ms, Me.PictureBox1.Image.RawFormat)
Dim arrayImage() As Byte = ms.GetBuffer
ms.Close() ' Closes the Memory Stream
Dim nStr As String = Me.Label1.Text.Substring(Me.Label1.Text.LastIndexOf("\") + 1)
Dim strQuery As String = "INSERT INTO Pic(Name, Picture) VALUES(@Name, @Picture)"
Dim objcommand As New SqlCommand(strQuery, Me.SqlConnection1)
With objcommand
.Parameters.Add(New SqlParameter("@Name", SqlDbType.NVarChar, 50)).Value = nStr
.Parameters.Add(New SqlParameter("@Picture", SqlDbType.Image)).Value = arrayImage
End With
Me.SqlConnection1.Open()
objcommand.ExecuteNonQuery()
MessageBox.Show("Image Saved Into the DataBase")
Me.SqlConnection1.Close()
Comment