Click here to Skip to main content
15,916,280 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends,

here iam new to MS access and wpf , please suggest me how to insert an image in MS access

similarly retriving .


thanking you.
Posted
Updated 10-Mar-14 23:58pm
v3
Comments
Mr.VJ 11-Mar-14 5:34am    
here getting an error as datatype mis match .. iam trying this one .please help me if u have any alternate solutions.


private void button1_Click(object sender, RoutedEventArgs e)
{
cmdd = new OleDbCommand();

string iname=Application.Current.Resources["iname"].ToString();

byte[] imagedata = File.ReadAllBytes(iname);


//var imageBuffer = BitmapSourceToByteArray((BitmapSource)image2.Source);
cmdd.CommandText = "INSERT into login([image],[imagename]) VALUES(@image,@imagename)";
cmdd.Connection = conn;
conn.Open();
OleDbParameter myParameter = new OleDbParameter("@image", OleDbType.LongVarBinary, imagedata.Length);

myParameter.Value = imagedata;

cmdd.Parameters.Add(myParameter);
//cmdd.Parameters.Add("@image", imageBuffer);
cmdd.Parameters.Add("@imagename", iname);
cmdd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("sucessfull");
}
CodingLover 11-Mar-14 6:25am    
Can you please post the error you comes with here to see?

1 solution

Read the image into a buffer and store it in the database as a BLOB.
 
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