Syntax error in INSERT INTO statement

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Saber (saber[--AT--]maghalat.com)
Date: 07/18/04


Date: Mon, 19 Jul 2004 00:30:57 +0430

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



Relevant Pages

  • Re: An error I cant find
    ... <% for i in @news %> ... I've removed all the code I could and don't understand why the case i.categorie produce a syntax error, unexpected tIDENTIFIER, expecting kWHEN ... <% when bar then foo %> ...
    (comp.lang.ruby)
  • HELP! Adobe Reader error in FC6
    ... expr: syntax error ... That is what I get in the console ... Expecting? ... Get great news right away with email Auto-Check. ...
    (Fedora)
  • weblog
    ... Over a year and a half ago, I started a weblog with Tom Waits related ... news. ... I try and keep the posts short and to the point ...
    (rec.music.artists.springsteen)
  • Re: A good book about creating a weblog?
    ... Weblog actually is not about web server logging... ... where you write news about you everyday, or you share your views abour the ...
    (alt.php)
  • SpaceShip Summer - New Blog; New Seti@Home team.
    ... Spaceship Summer is a weblog on space tourism, the X-Prize, and CATS ... Other important space exploration ... news and information will be covered as well. ...
    (sci.space.policy)