i keep getting a syntax error for the cmd code and i dont understand whats wrong, i have checked online everywhere but i cant seem to find a solutiom. This is the error "syntax error in INSERT INTO statement"
pro = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:UsershifzuDesktopCS A LEVELHolidayPlansHolidayPlansHPlansDB.accdb"
connstring = pro
myconnection.ConnectionString = connstring
myconnection.Open()
Dim cmd As New OleDb.OleDbCommand("INSERT INTO User Information ([Forename],[Surname],[DOB],[MobileNO],[Email Address]) VALUES ('" & TextBoxForename.Text & "','" & TextBoxSurname.Text & "','" & TextBoxAge.Text & "','" & TextBoxContactNO.Text & "','" & TextBoxEmail.Text & "')", myconnection)
cmd.Parameters.Add(New OleDbParameter("Forename", CType(TextBoxForename.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Surname", CType(TextBoxSurname.Text, String)))
cmd.Parameters.Add(New OleDbParameter("DOB", CType(TextBoxAge.Text, String)))
cmd.Parameters.Add(New OleDbParameter("MobileNO", CType(TextBoxContactNO.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Email Address", CType(TextBoxEmail.Text, String)))
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
myconnection.Close()
MsgBox("Info Saved", MsgBoxStyle.Information, "Successfully Added!")
TextBoxForename.Clear()
TextBoxSurname.Clear()
TextBoxAge.Clear()
TextBoxContactNO.Clear()
TextBoxEmail.Clear()
Catch ex As Exception
MsgBox(ex.Message)
End Try
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…