trying to INSERT with an AutoNumber on Access

Results 1 to 2 of 2

Thread: trying to INSERT with an AutoNumber on Access

  1. #1
    Join Date
    Dec 1969
    Posts
    572

    Default trying to INSERT with an AutoNumber on Access

    I have a webpage that will insert a record into an Access database based on a fillout form. The Primary Key for each record is an Access generated AutoNumber. How do i treat this in the ASP code? Here is the code:<BR><BR>SQLstmt = "INSERT INTO Album (AlbumID, Band, Title, Year, TopSong, Review, Llink, Blink, Rating) VALUES (??,&#039" & aband & "&#039,&#039" & atitle & "&#039," & ayear & ",&#039" & atopsong & "&#039,&#039" & areview & "&#039,&#039" & allink & "&#039,&#039" & ablink & "&#039," & arating & ")"<BR><BR>As you can see where the value for AlbumID(the AutoNumbered value) should go, i have ??. Do i even include the AlbumID field in the INSERT since its AutoNumbered? I tried leaving out the AlbumID field and its respective value altogether for the INSERT but still got errors.<BR><BR>The error i keep getting with the page when i exclude the AlbumID field is?<BR><BR>Error Number= #-2147217913<BR>Error description=[Microsoft][ODBC Microsoft Access 97 Driver] Data type mismatch in criteria expression.<BR><BR>I&#039m so stumped. Thanks.

  2. #2
    Jairo Guest

    Default RE: trying to INSERT with an AutoNumber on Access

    Alex,<BR>You shouldn&#039t be referencing the AutoNumber field. It will handle the increment itself.<BR>i.e.<BR>SQLstmt = "INSERT INTO Album (Band, Title, Year, TopSong, Review, Llink, Blink, Rating)<BR> VALUES ("&#039" & aband & "&#039,&#039" & atitle & "&#039," & ayear & ",&#039" & atopsong & "&#039,&#039" & areview & "&#039,&#039" & allink & "&#039,&#039" & ablink & "&#039," & arating & ")"<BR><BR>HTH,<BR>Jairo<BR>http://www.citywebarchitects.com

Posting Permissions

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