我不断收到错误System.Data.SQLite.SQLiteException:'靠近“ into”的SQL逻辑错误:语法错误”

时间:2019-10-16 09:11:58

标签: c# sql database sqlite

我无法弄清楚代码出了什么问题 enter image description here

System.Data.SQLite.SQLiteException:'SQL逻辑错误 “进入”附近:语法错误'

    private void BtnUpdate_Click(object sender, EventArgs e)
    {

        string StudentIDq = "update into Student (StudentID, ExamBoard, Firstname, Surname, Pure, Statistics, Mechanics, Total, " + "Average, Rank) values ('" + txtStudentID.Text + ", " + cmbExamBoard + ", " + txtFirstname.Text + "," + "" + txtSurname.Text + "," + txtPure.Text + ", " + txtStats.Text + "," + txtMechanics.Text + " + " + txtTS.Text + "," + txtAvrg.Text + "," + txtRank.Text + ")";


        ExecuteQuery(StudentIDq);
        LoadData();


    }

2 个答案:

答案 0 :(得分:-1)

  private void BtnUpdate_Click(object sender, EventArgs e)
{

    string StudentIDq = "insert into Student (StudentID, ExamBoard, Firstname, Surname, Pure, Statistics, Mechanics, Total, " + "Average, Rank) values ('" + txtStudentID.Text + ", " + cmbExamBoard + ", " + txtFirstname.Text + "," + "" + txtSurname.Text + "," + txtPure.Text + ", " + txtStats.Text + "," + txtMechanics.Text + " + " + txtTS.Text + "," + txtAvrg.Text + "," + txtRank.Text + ")";


    ExecuteQuery(StudentIDq);
    LoadData();


}

答案 1 :(得分:-1)

如果要更新列,查询将类似于

    string StudentIDq = "update Student set StudentID=" + txtStudentID.Text + ", ExamBoard= " + cmbExamBoard + ", Firstname='" + txtFirstname.Text + "', Surname='" + txtSurname.Text + "', Pure='" + txtPure.Text + "', Statistics='" + txtStats.Text + "', Mechanics='" + txtMechanics.Text + "' , Total=" + txtTS.Text + ", " + "Average=" + txtAvrg.Text + ", Rank=" + txtRank.Text + ") ;

还添加一个Where条件,否则所有列将被更新