Professional Web Applications Themes

INSERT statement contains fewer items than the insert list - ASP

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). ...

  1. #1

    Default INSERT statement contains fewer items than the insert list

    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 [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    J. Muenchbourg Guest

  2. #2

    Default Re: INSERT statement contains fewer items than the insert list

    On Tue, 30 Sep 2003 13:06:31 -0700, J. Muenchbourg <jodaddycanada.com> 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 [url]http://www.developersdex.com[/url] ***
    >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 Guest

  3. #3

    Default Re: INSERT statement contains fewer items than the insert list

    "J. Muenchbourg" <jodaddycanada.com> wrote in message
    news:uMJUY54hDHA.2320TK2MSFTNGP12.phx.gbl...
    > 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 [url]http://www.developersdex.com[/url] ***
    > 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 Guest

  4. #4

    Default Re: INSERT statement contains fewer items than the insert list

    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" <jodaddycanada.com> wrote in message
    news:uMJUY54hDHA.2320TK2MSFTNGP12.phx.gbl...
    > 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 [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Aaron Bertrand - MVP Guest

Similar Threads

  1. Question Insert from ASP to SQL using recordset data as values in insert statement
    By JasonM in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: June 13th, 05:54 PM
  2. Question Insert Items in DropDownList from Database in C# ASP.NET
    By Bijay in forum Brainstorming Area
    Replies: 0
    Last Post: June 2nd, 10:52 AM
  3. Help with INSERT INTO statement
    By s_jancich in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: July 20th, 04:39 PM
  4. access insert statement
    By Curt_C [MVP] in forum ASP
    Replies: 10
    Last Post: September 2nd, 04:04 PM
  5. Insert Statement help
    By ksbrace in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: June 30th, 02:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139