vb.net 2010中UPDATE语句访问数据库中的语法错误

时间:2021-07-23 14:27:21

I have just started VB.net for several weeks. I want to make a form and Add data from textboxes and update a database (*.accdb) file. but the code I have written gives the following error:

我刚刚开始使用VB.net几周了。我想创建一个表单并从文本框添加数据并更新数据库(* .accdb)文件。但是我写的代码给出了以下错误:

Syntax error in UPDATE statement.

UPDATE语句中的语法错误。

Private Sub Button1_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button1.Click
    ds6.Clear()
    cmd.Connection = con
    cmd.CommandText = "UPDATE Player SET pid='" + ComboBox3.Text + "', pfn='" _
        + TextBox2.Text + "',pmn='" + TextBox3.Text + "',pln='" + TextBox4.Text _
        + "',nic='" + TextBox5.Text + "',dob='" + DateTimePicker1.Value + "',telm='" _
        + MaskedTextBox1.Text + "',telh='" + MaskedTextBox2.Text + "',addr='" _
        + TextBox6.Text + "',email='" + TextBox10.Text + "',gndr='" + ComboBox1.Text _
        + "',weight='" + TextBox1.Text + "',hight'" + TextBox7.Text + "',sgrlvl'" _
        + TextBox11.Text + "',prate'" + TextBox8.Text + "' bloodg='" & ComboBox2.Text & "'"

    cmd.ExecuteNonQuery()
    MessageBox.Show("Player Updated")

    dssql6 = "select * from Player"
    da6 = New OleDb.OleDbDataAdapter(dssql6, con)
    da6.Fill(ds6, "Player")

    ComboBox1.Text = ("")
    ComboBox2.Text = ("")
    TextBox1.Text = ("")
    TextBox2.Clear()
    TextBox5.Clear()
    TextBox3.Clear()
    TextBox4.Clear()
    TextBox6.Clear()
    TextBox7.Clear()
    TextBox8.Clear()
    TextBox10.Clear()
    TextBox11.Clear()
    MaskedTextBox1.Clear()
    MaskedTextBox2.Clear()

End Sub

End Class

结束类

1 个解决方案

#1


4  

You're missing equal signs for hight, sgrlvl and prate. Although LarsTech is right, you should do this using parameters.

你错过了等高,sgrlvl和prate的等号。虽然LarsTech是对的,但你应该使用参数来做到这一点。

#1


4  

You're missing equal signs for hight, sgrlvl and prate. Although LarsTech is right, you should do this using parameters.

你错过了等高,sgrlvl和prate的等号。虽然LarsTech是对的,但你应该使用参数来做到这一点。