Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net VB中缺少语法运算符SQL insert_Vb.net - Fatal编程技术网

Vb.net VB中缺少语法运算符SQL insert

Vb.net VB中缺少语法运算符SQL insert,vb.net,Vb.net,我在Visual Basic中遇到“语法缺少运算符”错误 这是我的代码: cmd.Connection = conn 'add data to the database cmd.CommandText = "INSERT INTO [STUDENT REGISTRATION REPORT]([StudentID],[FirstName],[LastName],[Course],[YearLevel],[Department],[Age],[Gender],[Cleaning],[Cavi

我在Visual Basic中遇到“语法缺少运算符”错误

这是我的代码:

 cmd.Connection = conn
 'add data to the database

 cmd.CommandText = "INSERT INTO [STUDENT REGISTRATION REPORT]([StudentID],[FirstName],[LastName],[Course],[YearLevel],[Department],[Age],[Gender],[Cleaning],[CavityFilling],[Xray],[Flouride],[RootCanal])" & _
 "VALUES(" & studentid.Text & "','" & firstname.Text & "','" & lastname.Text & "','" & course.Text & "','" & yearlevel.Text & "','" & department.Text & "','" & _ age.Text & "','" & gender.Text & "','" & cleaning.Checked & "','" & cavityfilling.Checked & "','" & xray.Checked & "','" & flouride.Checked & "','" & _
                      rootcanal.Checked & "')"

    cmd.ExecuteNonQuery()

    'close connection

    conn.Close()

End Sub

使用SQL参数。这本身就解决了许多语法问题,并提高了安全性。异常消息通常有更多内容。但始终使用SQL参数。多年来,这一直不是编写SQL的正确方法。除了使用SQL参数外,您还应该使用以确保所有变量类型匹配。但是,这不会告诉您氟化物的正确拼写。可能在
和uu-age.Text&
处缺少换行符?或者删除下划线?标题需要更具体地使用SQL参数。这本身就解决了许多语法问题,并提高了安全性。异常消息通常有更多内容。但始终使用SQL参数。多年来,这一直不是编写SQL的正确方法。除了使用SQL参数外,您还应该使用以确保所有变量类型匹配。但是,这不会告诉您氟化物的正确拼写。可能在
和uu-age.Text&
处缺少换行符?或者删除下划线?标题需要更加具体