INSERT statement contains fewer items than the insert list

Discussion in 'ASP General' started by J. Muenchbourg, Sep 30, 2003.

  1. The block of code below shows how I am inserting field values into my
    dbase table:

    strSQLStatement = "INSERT INTO tblArticles
    (handid,ArticleDate,sport,articleheader, fpick,articleText) "_
    & "SELECT '" & handid & "' As handid, '" _
    & ArticleDate & "' As ArticleDate, '" _
    & sport & " As sport, " _
    & articleheader & "' As articleheader, '" _
    & fpick & "' As fpick, '" _
    & articleText & "' As articleText;"

    Conn.Execute(strSQLStatement)

    ...but I am getting an "Insert statement contains fewer items than the
    insert list" error , when in fact I am not (both 6 field names).

    ????
    Muench

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    J. Muenchbourg, Sep 30, 2003
    #1
    1. Advertising

  2. J. Muenchbourg

    Turkbear Guest

    On Tue, 30 Sep 2003 13:06:31 -0700, J. Muenchbourg <> wrote:

    >The block of code below shows how I am inserting field values into my
    >dbase table:
    >
    >strSQLStatement = "INSERT INTO tblArticles
    >(handid,ArticleDate,sport,articleheader, fpick,articleText) "_
    > & "SELECT '" & handid & "' As handid, '" _
    > & ArticleDate & "' As ArticleDate, '" _
    > & sport & " As sport, " _
    > & articleheader & "' As articleheader, '" _
    > & fpick & "' As fpick, '" _
    > & articleText & "' As articleText;"
    >
    > Conn.Execute(strSQLStatement)
    >
    >..but I am getting an "Insert statement contains fewer items than the
    >insert list" error , when in fact I am not (both 6 field names).
    >
    >????
    >Muench
    >
    >*** Sent via Developersdex http://www.developersdex.com ***
    >Don't just participate in USENET...get rewarded for it!


    Try a
    Response.Write (strSQLStatement)
    to see if perhaps the quotes or commas are getting misplaced...
    Turkbear, Sep 30, 2003
    #2
    1. Advertising

  3. "J. Muenchbourg" <> wrote in message
    news:...
    > The block of code below shows how I am inserting field values into my
    > dbase table:
    >
    > strSQLStatement = "INSERT INTO tblArticles
    > (handid,ArticleDate,sport,articleheader, fpick,articleText) "_
    > & "SELECT '" & handid & "' As handid, '" _
    > & ArticleDate & "' As ArticleDate, '" _
    > & sport & " As sport, " _
    > & articleheader & "' As articleheader, '" _
    > & fpick & "' As fpick, '" _
    > & articleText & "' As articleText;"
    >
    > Conn.Execute(strSQLStatement)
    >
    > ..but I am getting an "Insert statement contains fewer items than the
    > insert list" error , when in fact I am not (both 6 field names).
    >
    > ????
    > Muench
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!


    Try this:

    strSQLStatement = "INSERT INTO tblArticles
    > (handid,ArticleDate,sport,articleheader, fpick,articleText) "_
    > & "VALUES (" & handid & ", " _
    > & ArticleDate & ", " _
    > & sport & ", " _
    > & articleheader & ", " _
    > & fpick & ", " _
    > & articleText & ")"
    Harry Strybos, Sep 30, 2003
    #3
  4. Uh, did you mean

    strSQLStatement = "INSERT tblArticles (handid, ...) VALUES('" & handid & "',
    ....)"

    (I've never seen As used for aliases in an *insert* statement; not saying
    that it wouldn't work, but it looks weird, and bloats your code
    unnecessarily.)

    Also, a good debugging technique, as always, is

    Response.Write (strSQLStatement)

    In this case, you are very likely to spot the problem without having to post
    a message at all. And when you do have to post a message, you give us more
    useful information than an unpopulated SQL statement...







    "J. Muenchbourg" <> wrote in message
    news:...
    > The block of code below shows how I am inserting field values into my
    > dbase table:
    >
    > strSQLStatement = "INSERT INTO tblArticles
    > (handid,ArticleDate,sport,articleheader, fpick,articleText) "_
    > & "SELECT '" & handid & "' As handid, '" _
    > & ArticleDate & "' As ArticleDate, '" _
    > & sport & " As sport, " _
    > & articleheader & "' As articleheader, '" _
    > & fpick & "' As fpick, '" _
    > & articleText & "' As articleText;"
    >
    > Conn.Execute(strSQLStatement)
    >
    > ..but I am getting an "Insert statement contains fewer items than the
    > insert list" error , when in fact I am not (both 6 field names).
    >
    > ????
    > Muench
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Aaron Bertrand - MVP, Sep 30, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Dyer
    Replies:
    5
    Views:
    639
  2. =?Utf-8?B?Q2hhcmxpZSBEaXNvbg==?=

    Datagrid with fewer records than page size is ugly

    =?Utf-8?B?Q2hhcmxpZSBEaXNvbg==?=, Feb 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    440
    Alvin Bruney [MVP]
    Feb 29, 2004
  3. Gilles Kuhn
    Replies:
    0
    Views:
    426
    Gilles Kuhn
    Sep 15, 2003
  4. Anjan Bhowmik
    Replies:
    1
    Views:
    462
    Misbah Arefin
    Feb 14, 2008
  5. Kelly Dwight Felkins
    Replies:
    6
    Views:
    121
    Jeremy Henty
    Feb 9, 2006
Loading...

Share This Page