TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Safayat Zisan
NA
1.5k
501k
Getting exception while inserting image in access database
Jun 16 2015 2:43 PM
I am trying to insert an image to access database through my C# application. But every time I am getting exception
Here is my code:
private void button1_Click(object sender, EventArgs e)
{
try
{
connection.Open();
string str = "INSERT INTO imageInsertRetrieve (FirstName,LastName,Image) values ('" + textBox1.Text + "','" + textBox2.Text + "',(@img))";
cmd = new OleDbCommand(str, connection);
ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
byte[] photo_aray = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
cmd.Parameters.AddWithValue("@img", photo_aray);
cmd.ExecuteNonQuery();
}
catch(Exception exp)
{
MessageBox.Show(exp.ToString());
}
finally
{
connection.Close();
}
}
Reply
Answers (
3
)
Assemblies
Procedure or function 'Getproducts9' expects parameter '@Bra