0

I am coding in VB.NET and I'm getting this error when I'm trying to insert a record into my SQL database.

Public Sub SaveNames(ByRef SQLStatement As String)
    Dim cmd As MySqlCommand = New MySqlCommand

    With cmd
        .CommandText = SQLStatement
        .CommandType = CommandType.Text
        .Connection = SQLConnection
        .ExecuteNonQuery()
    End With
    SQLConnection.Close()
    MsgBox("Successfully Added")
    SQLConnection.Dispose()


End Sub

Private Sub cmdSave_Click(sender As Object, e As EventArgs) Handles cmdSave.Click
    Dim SQLStatement As String = "INSERT INTO people(name) VALUES (‘" & TextBox1.Text & "')"

    SaveNames(SQLStatement)

End Sub
Taylor
  • 2,981
  • 2
  • 29
  • 70

1 Answers1

0

Looks like you've got one of those microsoft funky quotes, not single quote character

VALUES (‘" & 
        ^

Replace that with a normal single quote, give it a whirl, and see how big of smoke ball it makes then.

spencer7593
  • 106,611
  • 15
  • 112
  • 140