Results 1 to 5 of 5

Thread: How can I fix this Syntax error in INSERT INTO statement.

  1. #1
    Join Date
    May 2004
    Location
    NewYork, USA
    Posts
    175
    Thanks
    25
    Thanked 0 Times in 0 Posts

    Default How can I fix this Syntax error in INSERT INTO statement.

    Hi,
    I need urgent help about ASP INSERT INTO statement.

    I have this code:


    'store the desired SQL statement into a variable
    'add the link as inactive 'N' as it needs admin approval
    sSQL="INSERT INTO tbllinks (Name,URL,Description,Date_Added,Active,Category," & _
    "Contact_Name,Contact_Email,Keywords,Contact_Tel,C ontact_Fax,user,pass) VALUES ('" & sName & "', '" & sURL & "','" & sDescription & "'," & _
    "'" & dDateAdded & "','N','" & iCategoryID & "','" & sContactName & "'," & _
    "'" & sContactEmail & "','" & sKeywords & "','" & sTel & "','" & sFax & "','" & sUser & "','" & sPass & "')"

    oConnection.execute(sSQL)





    when I submit form I recieve this error

    Microsoft JET Database Engineerror '80040e14'
    Syntax error in INSERT INTO statement. /Aadd_link_process.asp, line 100



    Line 100 is this

    oConnection.execute(sSQL)



    I've changed line 100 to

    response.write(sSQL)


    and I got this:

    INSERT INTO tbllinks (Name,URL,Description,Date_Added,Active,Category,C ontact_Name,Contact_Email,Keywords,Contact_Tel,Con tact_Fax,user,pass) VALUES ('ALI', 'http://www.mydomain.com','description','14/02/2008 17:31:23','N','21','John','flo697@hotmail.com','ad fvadfva','2164442233','2164442233','0123456789','2 2421395')



    Seem like there is no error

    So where is my mistake?

  2. #2
    Join Date
    May 2004
    Location
    NewYork, USA
    Posts
    175
    Thanks
    25
    Thanked 0 Times in 0 Posts

    Default

    I just found and fixed it...

    Something I learnt now. there are reserved words for MsAccess user was one of them, when I changed colum name to Main_User it's been fixed.

  3. #3
    Join Date
    Jan 2006
    Posts
    419
    Thanks
    2
    Thanked 16 Times in 16 Posts

    Default

    In SQL Server you can put the column name in [] brackets to get round reserved key words.

  4. The Following User Says Thank You to askjim For This Useful Post:

    RFH Reseller: HostCan (15th February 2008)

  5. #4
    Join Date
    May 2004
    Location
    NewYork, USA
    Posts
    175
    Thanks
    25
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jimlewis View Post
    In SQL Server you can put the column name in [] brackets to get round reserved key words.
    Thanks for the tip.
    Like this?

    'store the desired SQL statement into a variable
    'add the link as inactive 'N' as it needs admin approval
    sSQL="INSERT INTO tbllinks ([Name],URL],[Description],[Date_Added],[Active],[Category]," & _
    "[Contact_Name],[Contact_Email],[Keywords],[Contact_Tel],[C ontact_Fax],[user],[pass]) VALUES ('" & sName & "', '" & sURL & "','" & sDescription & "'," & _
    "'" & dDateAdded & "','N','" & iCategoryID & "','" & sContactName & "'," & _
    "'" & sContactEmail & "','" & sKeywords & "','" & sTel & "','" & sFax & "','" & sUser & "','" & sPass & "')"

    oConnection.execute(sSQL)

  6. #5
    Join Date
    Feb 2004
    Posts
    4,903
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Yes, but you don't need to do them all - just the reserved ones.
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  7. The Following User Says Thank You to Warren Ashcroft For This Useful Post:

    RFH Reseller: HostCan (21st February 2008)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I need help for a sql statement
    By HostCan in forum ASP (VBScript)
    Replies: 2
    Last Post: 26th January 2008, 01:33 AM
  2. Invalid syntax on line 196.
    By garazy in forum ASP.NET
    Replies: 1
    Last Post: 29th January 2007, 08:47 AM
  3. Replies: 16
    Last Post: 2nd December 2005, 04:09 PM
  4. osCommerce PHP5 fix
    By dv8host in forum osCommerce (PHP)
    Replies: 12
    Last Post: 10th June 2005, 08:15 AM

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
  •