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

时间:2016-04-29 13:23:33

标签: .net vb.net

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

  

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

结束班

1 个答案:

答案 0 :(得分:3)

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

相关问题