Here is a simple example of how to insert an image into a SQL Server database. The image will be stored as a binary file.
Sub SaveImage()
Dim con As New SqlClient.SqlConnection("connection string goes here")
Dim cmd As SqlClient.SqlCommand()
cmd = New SqlClient.SqlCommand("Insert into tableName (Image) Values(@image)", con)
'Use may fileUplaod control to select your image
Using nPic As Image = Image.FromFile("image path goes here")
Using stream As New IO.MemoryStream
nPic.Save(stream, Imaging.ImageFormat.Gif)
cmd.Parameters.Add("@image", SqlDbType.VarBinary).Value = stream.GetBuffer()
End Using
End Using
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Sub
You can use a FileUpload to specify the path of the image.




