how do i want to save a picture in accsess database?

'You can create Varbinary(Max) datatype for image column
'Below is code to store Image
Imports System.Data.SqlClient

Dim myfilelocation As String = "C:\myPictures\myimage.jpg" 
        Dim conn As New SqlConnection("Data Source= .\sqlexpress; Initial Catalog=Temp;Integrated Security =True") 
        Dim cmd As New SqlCommand("Insert Into ImageTable(ImageFile,CustomerID) Values (@ImageData,@CustomerID)", conn) 
 
        Dim param As New SqlParameter("@ImageData", SqlDbType.VarBinary) 
        Dim ImageData As Byte() = IO.File.ReadAllBytes(myfilelocation) 
        param.Value = ImageData 
        cmd.Parameters.Add(param) 
 
        cmd.Parameters.AddWithValue("@CustomerID", 3) 
        Try 
            conn.Open() 
            cmd.ExecuteNonQuery() 
        Catch ex As Exception 
            MessageBox.Show(ex.Message) 
        Finally 
            conn.Close() 
        End Try 



'And Below is the code to retrieve

Dim conn As New SqlConnection("Data Source= .\sqlexpress; Initial Catalog=Temp;Integrated Security =True") 
        Dim cmd As New SqlCommand("select ImageFile from ImageTable where CustomerID=@CustomerID ", conn) 
        cmd.Parameters.AddWithValue("@CustomerID", 3) 
        Try 
            conn.Open() 
            PictureBox1.Image = Image.FromStream(New IO.MemoryStream(CType(cmd.ExecuteScalar, Byte()))) 
         ' or you can save in a file 
  'IO.File.WriteAllBytes("c:\backup\image3.jpg", CType(cmd.ExecuteScalar, Byte()))
        Catch ex As Exception 
            MessageBox.Show(ex.Message) 
        Finally 
            conn.Close() 
        End Try

hello firend,my mean is save picture in access database and i want to put the image in picture box in my form.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.