INSERT INTO 语句的语法错误。
程序代码:
错误提示在最下面一行,if语句执行没有问题。 private void button1_Click(object sender, EventArgs e) { OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb"); aConnection.Open(); string strName; strName = "insert into user(name,password,qx) values(" + textBox1.Text + ",'" + textBox2.Text + "'," + textBox3.Text + ")"; if (textBox1.Text == "" | textBox2.Text == "" | textBox3.Text == "" ) { MessageBox.Show("请填写要添加的数据"); return; } OleDbDataAdapter myadapter = new OleDbDataAdapter(strName, aConnection); //执行查询 DataSet ds = new DataSet(); //新建数据集 myadapter.Fill(ds);//将SQL执行结果,填入数据集ds中可自加数据,进行验证 }