hi all,
Whenever i try to insert data into Access db its through me syntax error exception, i tried everything but still error is coming
What I have tried:
Insert code:
cmd = new OleDbCommand("insert into RegistrationForm(ClientCount,Name,Address,Contact,Documents,Money_Taking_Date,Muddat,Money_Return_date,Account_status,Taking_Amout,Interest_per_month,Pending_interest_month,Pending_interst_Amount,Total_Amount,Client_image,Document_image1,Document_image2) values(" + lblcount.Text + "','" + textBox20.Text + "','" + textBox21.Text + "','" + textBox19.Text + "','" + textBox18.Text + "','" + maskedTextBox1.Text.ToString() + "','" + textBox22.Text + "','" + maskedTextBox2.Text.ToString() + "','" + textBox23.Text + "','" + textBox17.Text + "','" + textBox16.Text + "','" + textBox15.Text + "','" + Convert.ToDouble(textBox13.Text) + "','" + Convert.ToDouble(textBox14.Text) + "',@pictureBox6,@pictureBox4,@pictureBox5)'", con);
conv_photo();
con.Open();
int n = cmd.ExecuteNonQuery(); -- exception coming on this line
con.Close();
if (n > 0)
{
MessageBox.Show("record inserted");
loaddata();
rno++;
}
else
MessageBox.Show("insertion failed");
conv_photo method:
public void conv_photo()
{
//converting photo to binary data
if (pictureBox6.Image != null)
{
//using MemoryStream:
ms = new MemoryStream();
pictureBox6.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] photo_aray = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
cmd.Parameters.AddWithValue("@pictureBox6", photo_aray);
}
if (pictureBox4.Image != null)
{
//using MemoryStream:
ms = new MemoryStream();
pictureBox4.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] photo_aray = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
cmd.Parameters.AddWithValue("@pictureBox4", photo_aray);
}
if (pictureBox5.Image != null)
{
//using MemoryStream:
ms = new MemoryStream();
pictureBox5.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] photo_aray = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
cmd.Parameters.AddWithValue("@pictureBox5", photo_aray);
}
}
output is :
'2','Atul','india','4589787978','collected','12/05/2015','4','12/06/2015','Active','5000','500','5','2500','7500',@pictureBox6,@pictureBox4,@pictureBox5)'.