我想将数据插入数据库。输入的格式与分配的格式相同,但是会发生此错误
System.Data.OleDb.OleDbException:'条件中的数据类型不匹配
表达。”
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] photo = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo, 0, photo.Length);
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
cmd.CommandText = "insert into Animaldata(dartadate,dartano,cardno,animalname,huliya,age,layakoplace,color,situtation,animalowner,adress,contact,waliname,walidate,picture) values('" + dartadatetext.Text + "','" + dartanotext.Text + "','" + cardnotext.Text + "','" + animalnametext.Text + "','" + huliyatext.Text + "','" + agetext.Text + "','" + layakoplacetext.Text + "','" + colortext.Text + "','" + health.ToString() + "','" + animalownertext.Text + "','" + addresstext.Text + "','" + contacttext.Text + "','" + walinametext.Text + "','" + walidatetext.Text + "',@photo)";
cmd.Parameters.AddWithValue("@photo", photo);
cmd.ExecuteNonQuery();
MessageBox.Show("Saved Successfuly");
con.Close();