hi,
I am using an access database and i have a form with a text box for entering the email address. I keep on getting errors each time i save to the database, below is the code i use
Try
sql = "INSERT INTO customers (fname,lname,mobileNo,email,countryID,IDTypeID,identification,roomNo,dateIn,daysIn,dateOut,noOfAdults,noOfChildren,adultTotal,childrenTotal,Total)" & _
"VALUES(" & txtfname.Text & "," & txtlname.Text & "," & txtphone.Text & "," & txtemail.Text.ToLower.ToString & "" & _
"," & cbocountry.SelectedIndex & "," & cboIdType.SelectedIndex & "," & txtId.Text & "," & rumNum & "" & _
"," & dtpCheckIn.Value.ToString & "," & txtDaysStaying.Text & "," & dtpCheckOut.Value.ToString & "" & _
"," & txtNoOfAdults.Text & "," & txtNoOfChildren.Text & "," & txtAdultTotal.Text & "" & _
"," & txtChildrenTotal.Text & "," & txtTotalAmount.Text & ")"
Using cmdInsert As New OleDb.OleDbCommand(sql, con)
connectDatabase()
cmdInsert.ExecuteNonQuery()
DisconnectDB()
dachk.Update(dsChk, "client")
End Using
Catch ex As Exception
MessageBox.Show(ex.ToString)
Clipboard.SetText(ex.ToString)
End Try
and here is exception error i am getting
System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'mwanikiphillip@gmail.com'.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Albergo.frmCheckIn.saveToDB() in C:\Users\gman\Documents\Visual Studio 2008\Projects\Albergo\Albergo\frmCheckIn.vb:line 76
Help would definitely be grateful