S
Saber
I'm using a table named myTable in Access, but when I try it I get:
Syntax error in INSERT INTO statement.
in access db, the Cat1,Cat2,..,Cat5 are Yes/No and their format is
True/False
any idea?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
here is a piece of code:
strSqlPost = "Insert into
myTable(title,text,type,date,authorid,Cat1,Cat2,Cat3,Cat4,Cat5)
Values(@title,@text,@type,@date,@authorid,@Cat1,@Cat2,@Cat3,@Cat4,@Cat5)"
cmdSqlPost = New OleDbCommand(strSqlPost, conPost)
cmdSqlPost.Parameters.Add("@title", txtTitle.Text)
cmdSqlPost.Parameters.Add("@text", txtBody.Text)
Select Case drpType.SelectedValue
Case "weblog"
cmdSqlPost.Parameters.Add("@type", 1) 'means weblog
Case "news"
cmdSqlPost.Parameters.Add("@type", 2) 'means news
Case "article"
cmdSqlPost.Parameters.Add("@type", 3) 'means article
End Select
cmdSqlPost.Parameters.Add("@date", Now.Date)
cmdSqlPost.Parameters.Add("@authorid", 23)
'cmdSqlPost.Parameters.Add("@cat1", chkCats.Items(0).Selected)
'cmdSqlPost.Parameters.Add("@cat2", chkCats.Items(1).Selected)
'cmdSqlPost.Parameters.Add("@cat3", chkCats.Items(2).Selected)
'cmdSqlPost.Parameters.Add("@cat4", chkCats.Items(3).Selected)
'cmdSqlPost.Parameters.Add("@cat5", chkCats.Items(4).Selected)
cmdSqlPost.Parameters.Add("@Cat1", False)
cmdSqlPost.Parameters.Add("@Cat2", False)
cmdSqlPost.Parameters.Add("@Cat3", True)
cmdSqlPost.Parameters.Add("@Cat4", False)
cmdSqlPost.Parameters.Add("@Cat5", False)
Try
ConnectDB(conPost)
cmdSqlPost.ExecuteNonQuery()
DisconnectDB(conPost)
lblStatus.ForeColor = Drawing.Color.Green
lblStatus.Text = "OK"
Catch ex As Exception
lblStatus.ForeColor = Drawing.Color.Red
lblStatus.Text = ex.Message
End Try
Syntax error in INSERT INTO statement.
in access db, the Cat1,Cat2,..,Cat5 are Yes/No and their format is
True/False
any idea?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
here is a piece of code:
strSqlPost = "Insert into
myTable(title,text,type,date,authorid,Cat1,Cat2,Cat3,Cat4,Cat5)
Values(@title,@text,@type,@date,@authorid,@Cat1,@Cat2,@Cat3,@Cat4,@Cat5)"
cmdSqlPost = New OleDbCommand(strSqlPost, conPost)
cmdSqlPost.Parameters.Add("@title", txtTitle.Text)
cmdSqlPost.Parameters.Add("@text", txtBody.Text)
Select Case drpType.SelectedValue
Case "weblog"
cmdSqlPost.Parameters.Add("@type", 1) 'means weblog
Case "news"
cmdSqlPost.Parameters.Add("@type", 2) 'means news
Case "article"
cmdSqlPost.Parameters.Add("@type", 3) 'means article
End Select
cmdSqlPost.Parameters.Add("@date", Now.Date)
cmdSqlPost.Parameters.Add("@authorid", 23)
'cmdSqlPost.Parameters.Add("@cat1", chkCats.Items(0).Selected)
'cmdSqlPost.Parameters.Add("@cat2", chkCats.Items(1).Selected)
'cmdSqlPost.Parameters.Add("@cat3", chkCats.Items(2).Selected)
'cmdSqlPost.Parameters.Add("@cat4", chkCats.Items(3).Selected)
'cmdSqlPost.Parameters.Add("@cat5", chkCats.Items(4).Selected)
cmdSqlPost.Parameters.Add("@Cat1", False)
cmdSqlPost.Parameters.Add("@Cat2", False)
cmdSqlPost.Parameters.Add("@Cat3", True)
cmdSqlPost.Parameters.Add("@Cat4", False)
cmdSqlPost.Parameters.Add("@Cat5", False)
Try
ConnectDB(conPost)
cmdSqlPost.ExecuteNonQuery()
DisconnectDB(conPost)
lblStatus.ForeColor = Drawing.Color.Green
lblStatus.Text = "OK"
Catch ex As Exception
lblStatus.ForeColor = Drawing.Color.Red
lblStatus.Text = ex.Message
End Try