DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2004
    Posts
    3

    HELP! Problems with INSERT

    I'm using IIS, Access 2000 for database, and ASP/ADO.

    I need to add a record to a table. I've checked my code and made a lot of changes and it still doesn't work. IE gives me this message: "Syntax error in INSERT INTO statement".

    Would someone please take a look at my code and tell me how to fix it?
    Thanx!!!!!

    heres my code:

    <%
    User=Request.Form("txtUsername")
    Pass=Request.Form("txtPassword")

    set conntemp=Server.CreateObject("ADODB.Connection")
    conntemp.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")

    sql="INSERT INTO LoginTable (username,password)"
    sql=sql & " VALUES ('" & User
    sql=sql & "','" & Pass
    sql=sql & "')"

    conntemp.execute(sql)
    set conntemp = Nothing
    %>

  2. #2
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557
    try this:

    sql="INSERT INTO LoginTable (username, password)" _
    & " VALUES (" & User & ", " & Pass & ")"

  3. #3
    Join Date
    Aug 2004
    Posts
    3
    It gives me the same thing... syntax error in INSERT INTO statement.
    It references to the code line where the conntemp.execute(sql) appears.

    I really don't understand why...
    Last edited by nectar; 08-13-2004 at 09:10 PM.

  4. #4
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557
    Is the table named [LoginTable]? Is there a space in it?

  5. #5
    Join Date
    May 2004
    Location
    India
    Posts
    20
    I think the connection string is giving you the problem try this out.
    This worked out for me.

    <%
    User=Request("txtUsername")
    Pass=Request("txtPassword")

    set conntemp=Server.CreateObject("ADODB.Connection")

    ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Persist Security Info=False;DBQ=" & Server.MapPath(".") & "/users.mdb"
    conntemp.Open ConnectionString

    strsql=" INSERT INTO LoginTable (username,password)"
    strsql=strsql & " VALUES ('" & User
    strsql=strsql & "', '" & Pass
    strsql=strsql & "') "

    conntemp.Execute strsql


    set conntemp = Nothing
    %>

    Hope it solves your issue.
    -Nagasree

  6. #6
    Join Date
    Aug 2004
    Posts
    3
    I tried it but another error appeared, this time on line 15 (conntemp.Execute strsql).

    IE gives me

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

    Laurel... my table's name is LoginTable, no spaces in between.

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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links