'email' 附近的不正确语法错误

Incorrect syntax error near 'email'

我正在 运行宁 Visual studio,每当我 运行 我的应用程序时,它都会显示 "Incorrect syntax error near '(the email i enter appears here)'"。我希望你能发现错误。

在 SQL 服务器中,我的电子邮件列名为 'email'

在 Visual studio 中,我的电子邮件的输入字段名称称为 'textEmail'

Public Sub AddCustomer(Firstname As String, Surname As String, Contactnum As String, Email As String)
    Try
        Dim strInsert As String = "INSERT INTO customers (firstname, surname, contactnum, email) " & _
                                  "VALUES  (" & _
                                  "'" & Firstname & "'," & _
                                  "'" & Surname & "'," & _
                                  "'" & Contactnum & "'," & _
                                  "'" & Email & "'"

        MsgBox(strInsert)

        SQLCon.Open()
        SQLcmd = New SqlCommand(strInsert, SQLCon)

        SQLcmd.ExecuteNonQuery()


        SQLCon.Close()

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try





End Sub

End Class

表单中的代码:

    Private Sub cmdSave_Click(sender As Object, e As EventArgs) Handles cmdSave.Click
    'QUERY FOR CUSTOMER
    SQL.RunQuery("SELECT * FROM customers WHERE customers.email = '" & txtEmail.Text & "' ")

    If SQL.SQLDS.Tables(0).Rows.Count > 0 Then
        MsgBox("This Email alredy exists!")
        Exit Sub
    Else
    CreateCustomer()
    End If
End Sub

      Public Sub CreateCustomer()
    ' ADD CUSTOMER TO DATABASE
    SQL.AddCustomer(txtFirst.Text, txtSur.Text, txtNum.Text, txtEmail.Text)


End Sub
End Class

感谢您的宝贵时间。

您缺少右括号

Dim strInsert As String = "INSERT INTO customers (firstname, surname, contactnum, email) " & _
                                  "VALUES  (" & _
                                  "'" & Firstname & "'," & _
                                  "'" & Surname & "'," & _
                                  "'" & Contactnum & "'," & _
                                  "'" & Email & "')"