将数据插入MS Access,收到错误“INSERT INTO语句中的语法错误”。 VB

时间:2016-03-25 15:27:38

标签: vb.net ms-access-2007

好的我是新手,我不知道我在做什么,我真的需要帮助

 Dim lnkr As New OleDbCommand(String.Format("insert into project (Student Name, Days Absent, Classes Absent, Arabic, Islamic, English, Math, Biology, Chemistry, Physic, Computer,Day Offs) values ('{0}',{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", TextBox1.Text, TextBox10.Text, TextBox12.Text, TextBox2.Text, TextBox6.Text, TextBox3.Text, TextBox4.Text, TextBox7.Text, TextBox5.Text, TextBox9.Text, TextBox8.Text, TextBox11.Text))

    lnkr.Connection = con
    con.Open()
    lnkr.ExecuteNonQuery()

    con.Close()

1 个答案:

答案 0 :(得分:0)

您错过了占位符{12}:

String.Format("insert into project ([Student Name], [Days Absent], [Classes Absent], Arabic, Islamic, English, Math, Biology, Chemistry, Physic, Computer, [Day Offs]) values ('{0}', {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}", TextBox1.Text, TextBox10.Text, TextBox12.Text, TextBox2.Text, TextBox6.Text, TextBox3.Text, TextBox4.Text, TextBox7.Text, TextBox5.Text, TextBox9.Text, TextBox8.Text, TextBox11.Text))

无法判断位置是否正确。