Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how to store an image in database in vb.net?
Posted

 
Share this answer
 
v2
Hi,
Here is a sample code


VB
Try
                    con.ConnectionString = str
                    con.Open()
                    Dim cmd As SqlCommand = New SqlCommand("insert into Empdetails(Image) values(@ImageData)", cn)
                    ' Add code for other Parameter
                    ' Code for Image Parameter
                    Dim param As New SqlParameter("@ImageData", SqlDbType.VarBinary)
                    Dim ImageData As Byte() = IO.File.ReadAllBytes(PictureBox1.ImageLocation)
                    param.Value = ImageData
                    cmd.Parameters.Add(param)
                    cmd.ExecuteNonQuery()
                    MsgBox("Added!")
                Catch ex As Exception
                    MsgBox(ex.Message)
                Finally
                    con.Close()
                End Try
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900