Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all
can some one share code to insert image in ms access database using c# , windows form application

thanks
Posted

This is the SQL version I use - the access version is the same, except you replace the SqlConnection and SqlCommand with whatever you are using.
C#
using (SqlConnection con = new SqlConnection(connectionString))
    {
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (myImage) VALUES (@IM)", con))
        {
        byte[] imageData = File.ReadAllBytes(@"F:\Temp\Picture.jpg");
        com.Parameters.AddWithValue("@IM", imageData);
        com.ExecuteNonQuery();
        }
    }
 
Share this answer
 
Comments
Member 8893861 15-Oct-12 5:35am    
Than u v much
What data type i should use using access
and data type OLEObject
regards
OriginalGriff 15-Oct-12 5:39am    
VARBINARY(MAX)
convert image to bytearray and store it to access and same way retrive that array and convert again back to image
 
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