how i save and open the image from the database?

williamku87

Member
Joined
Jun 25, 2008
Messages
7
Programming Experience
Beginner
who can help me in vb.net code for save and open the image from the database?
thanks
 
Last edited:
this should put an image in and you should be able to reverse it to get it out

VB.NET:
Dim connection As New SqlConnection(TextBox1.Text)



       

        ' Insert the image and comment into the database 
        Try
 Dim oImg As FileStream = New FileStream("C:\SteelCoil.jpg", FileMode.Open, FileAccess.Read)
        Dim oBinaryReader As BinaryReader = New BinaryReader(oImg)
        Dim oImgByteArray As Byte() = oBinaryReader.ReadBytes(CType(oImg.Length, Integer))

            connection.Open()
            Dim cmd As New SqlCommand("update TABLE set FIELD = @pic where FIELD= '123'", connection)
            cmd.Parameters.Add("@pic", oImgByteArray)
            cmd.ExecuteNonQuery()


            
            catch

end try
 

Latest posts

Back
Top