2 Attachment(s)
[RESOLVED] Syntax Error in Insert Statement
Hello All
This is really troubling me since morning. After 4 cups of Coffee and 2 cups of Tea I am still unable to spot the error....
vb Code:
'~~> Save data to database
Dim strSQL As String
Dim mobjConn As ADODB.Connection
Dim mobjCmd As ADODB.Command
Dim mobjRst As ADODB.Recordset
Set mobjConn = New ADODB.Connection
mobjConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=c:\" & "LSS.mdb"
mobjConn.Open
Set mobjCmd = New ADODB.Command
Set mobjCmd.ActiveConnection = mobjConn
mobjCmd.CommandType = adCmdText
strSQL = "INSERT INTO Table1 ("
strSQL = strSQL & "'" & DTPicker1.Value & "',"
strSQL = strSQL & "'" & Combo1.Text & "',"
strSQL = strSQL & "'" & Combo2.Text & "',"
strSQL = strSQL & "'" & Combo3.Text & "',"
strSQL = strSQL & "'" & Text1.Text & "',"
strSQL = strSQL & "'" & Text2.Text & "',"
strSQL = strSQL & "'" & Text3.Text & "',"
strSQL = strSQL & "'" & Combo4.Text & "',"
strSQL = strSQL & "'" & Combo5.Text & "')"
'~~>MsgBox strSQL
mobjCmd.CommandText = strSQL
mobjCmd.Execute strSQL
Set mobjRst = Nothing
Set mobjCmd = Nothing
mobjConn.Close
Set mobjConn = Nothing
BTW I also tried this but no joy...
vb Code:
strSQL = "INSERT INTO Table1( Date"
strSQL = strSQL & ", LoginID"
strSQL = strSQL & ", Advisor"
strSQL = strSQL & ", Verifier"
strSQL = strSQL & ", Customer"
strSQL = strSQL & ", ContactNo"
strSQL = strSQL & ", DebtAdvisor"
strSQL = strSQL & ", Client"
strSQL = strSQL & ", Program"
strSQL = strSQL & ") VALUES ("
strSQL = strSQL & "'" & DTPicker1.Value & "'"
strSQL = strSQL & ", '" & Combo1.Text & "'"
strSQL = strSQL & ", '" & Combo2.Text & "'"
strSQL = strSQL & ", '" & Combo3.Text & "'"
strSQL = strSQL & ", '" & Text1.Text & "'"
strSQL = strSQL & ", '" & Text2.Text & "'"
strSQL = strSQL & ", '" & Text3.Text & "'"
strSQL = strSQL & ", '" & Combo4.Text & "'"
strSQL = strSQL & ", '" & Combo5.Text & "')"
Snapshot of the error is attached. Also attached is the snapshot of the table structure...
Could it be possible because of the field called "Date"???
Re: Syntax Error in Insert Statement
Got it... How Dumb!!!
I answered my own question...
I changed the Date column to Tdate and it worked...