private void Save_Click(object sender, EventArgs e)
{
try
{
//判断所有字段是否添完,添完则执行,反之弹出提示
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "" && textBox6.Text != "" && textBox7.Text!="")
{
string strConn = @" Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = D:\C#\Display Control\检测结果.mdb ";
OleDbConnection myConn = new OleDbConnection(strConn);
//把Dataset绑定books数据表 2007-08-08 10:10:10
// myCommand.Fill(myDataSet, "数据检测");
myConn.Open();
string strInsert = " INSERT INTO 数据检测 ( 图像,结果,高度1,高度2,灰度值,序号,检测时间 ) VALUES ( '";strInsert += textBox1.Text.ToString() + "', '";strInsert += textBox2.Text.ToString() + "', '";strInsert += textBox3.Text.ToString() + "', '";strInsert += textBox4.Text.ToString() + "', '";strInsert += textBox5.Text.ToString() + "','";strInsert += textBox6.Text.ToString() + "','";strInsert += textBox7.Text.ToString() + "')";
OleDbCommand inst = new OleDbCommand(strInsert, myConn);
inst.ExecuteNonQuery();
myConn.Close();
}
else
{
MessageBox.Show("必须填满所有字段值!", "错误!");
}
}
catch (Exception ed)
{
MessageBox.Show("保存数据记录发生 " + ed.ToString(), "错误!");
}
}
运行后提示 查询值的数目与目标字段中的数目不同
大家帮我看看是哪儿的毛病