private void button1_Click(object sender, EventArgs e)
{
string a = textBox1.Text;
string b = textBox2.Text;
string c = textBox3.Text;
string d = textBox4.Text;
OleDbCommand cmd = new OleDbCommand(@"insert into patientvalues(" + a + ",'" + b + "'," + c + ",'" + d + "',con)");
connection.Open();
cmd.Connection = connection;
cmd.ExecuteNonQuery();
connection.Close();
this.Hide();
cmd.ExecuteNonQuery();這提示未處理OleDbExcertion(查詢值的數目與目標字段中的數目不同)
insert into patientvalues(" + a + ",'" + b + "'," + c + ",'" + d + "',con)");
是這句話出錯了
首先 patientvalues 中間應該有空格" patient values"
其次 你patient中是不是不止4列?你要不寫明白插入的是哪四列,要不就在values中不全
如 insert into patient(a,b,c,d) values(a,b,c,d)
要不就改成 insert into patient values(a,b,c,d,'') 假設patient中有五列