Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

asp, sql insert statement

  • 24-01-2005 03:54PM
    #1
    Registered Users, Registered Users 2 Posts: 483 ✭✭


    lo,
    im tryin to add records into a database and i was wonderin if i need to put in a value for my ID field (which is the autonumber field) in my insert sql statement!

    strSQL = "INSERT INTO Userinfo (Username,Password,FName,LName,Address,Email,Phone) VALUES ('" & Username & "','" & Password & "','" & Fname & "','" & LName & "','" & Address & "','" & Email & "','" & Phone & "')"

    when i try to execute the statement i get this message: Syntax error in INSERT INTO statement.


Comments

  • Registered Users, Registered Users 2 Posts: 3,890 ✭✭✭cgarvey


    Any of those variable values have a ' in them?

    .cg


  • Moderators, Politics Moderators, Paid Member Posts: 44,224 Mod ✭✭✭✭Seth Brundle


    Is phone text or integer?
    Sometimes I have found that field names 'username' and 'password' don't work until I place them in square brackets, i.e.
    "INSERT INTO Userinfo ([Username],[Password],[FName]...
    
    also read www.webthang.co.uk/tuts/tuts_dbase/rwords/pf/rwords_pf.asp

    Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/ .



  • Registered Users, Registered Users 2 Posts: 706 ✭✭✭DJB


    Like kbannon mentioned... some field names conflict with functions and controls in vb, sql, etc. Can't remember many of them but I do remember having this problem a few years back. Solved it by using a standard for naming tables and fields in the table so that they do not conflict with these values. It's like using a variable name called "request" in asp/vb. It just ain't going to happen!!!

    Here's what I use as default for table names and field names:

    Example 1:

    TBL_USERS
    US_ID
    US_FIRST
    US_LAST
    US_USERNAME
    US_PASSWORD
    etc.

    TBL_PAGES
    PG_ID
    PG_NAME
    etc.

    That's only my own standard that I use but you could you tblUsers or tblPages and usUserId, usFirst or pgId, pgName, etc.

    Hope that makes sense. Try it and see how you get on :)


Advertisement