Hi everyone
I'm really exhausted with this error
I'm using visual studio and I'm trying to build a contact form
And all the information should be saved in contact table in the database
Would you please help me with this error?
I tried a lot to figure what's wrong, but I couldn't
I'm sure that the spelling is correct and the order of the field
each time I click submit no error except this {Syntax error in INSERT INTO statement}
What's wrong with my code?
Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
Dim myConnection As OleDb.OleDbConnection
Dim myCommand As OleDb.OleDbCommand
Dim sql As String
Dim ra As Integer
myConnection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=N:\Web\cupcake\cupcakeDB.accdb;")
Try
myConnection.Open()
sql = "Insert into contact (fname, email, msg) values ('" & txtname.Text & "', '" & txtmail.Text & "', '" & txtmsg.Text & "', )"
myCommand = New OleDb.OleDbCommand(sql, myConnection)
ra = myCommand.ExecuteNonQuery()
lblmessage.Text = "msg sent " & ra
myConnection.Close()
Catch ex As Exception
lblmessage.Text = ex.Message
Finally
myCommand = Nothing
myConnection = Nothing
End Try
End Sub
Thanx in advance