Results 1 to 4 of 4

Thread: Add New Record to SQL with ADO

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    51

    Post

    The following is my code:<%
    on error resume next
    'form_name=Request.QueryString("name")

    ID = Request.QueryString("ID")
    USER= Request.QueryString("USER")
    WRKS_NAME= Request.QueryString("WRKS_NAME")
    WRKS_TYPE= Request.QueryString("WRKS_TYPE")
    SERIAL_NUM= Request.QueryString("SERIAL_NUM")
    LOCATION= Request.QueryString("LOCATION")
    DEPARTMENT= Request.QueryString("DEPARTMENT")
    PROCESSOR= Request.QueryString("PROCESSOR")

    conn="DSN=INVENTORY;uid=invuser;pwd=invpassword"
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open "Main",Conn,adopenstatic,adlockoptimistic
    'Main is the table

    RS.AddNew

    rs.Fields("ID") = ID
    rs.Fields("USER")= USER
    RS.Fields("WORKSTATION NAME")= WRKS_NAME
    RS.Fields("WORKSTATION TYPE")= WRKS_TYPE
    RS.Fields("SERIAL NUMBER")= SERIAL_NUM
    RS.Fields("LOCATION")= LOCATION
    RS.Fields("DEPARTMENT")= DEPARTMENT
    RS.Fields("PROCESSOR")= PROCESSOR

    rs.Update
    rstemp.Close
    set rstemp=nothing
    response.redirect "inventory1.asp"
    %>

    There is no error, but no record is add. Did I do something wrong here?

    Thanks

  2. #2
    Guest

    Post

    remove on error resume next and find out what the error is

    Originally posted by ptran:
    The following is my code:<%
    on error resume next
    'form_name=Request.QueryString("name")

    ID = Request.QueryString("ID")
    USER= Request.QueryString("USER")
    WRKS_NAME= Request.QueryString("WRKS_NAME")
    WRKS_TYPE= Request.QueryString("WRKS_TYPE")
    SERIAL_NUM= Request.QueryString("SERIAL_NUM")
    LOCATION= Request.QueryString("LOCATION")
    DEPARTMENT= Request.QueryString("DEPARTMENT")
    PROCESSOR= Request.QueryString("PROCESSOR")

    conn="DSN=INVENTORY;uid=invuser;pwd=invpassword"
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open "Main",Conn,adopenstatic,adlockoptimistic
    'Main is the table

    RS.AddNew

    rs.Fields("ID") = ID
    rs.Fields("USER")= USER
    RS.Fields("WORKSTATION NAME")= WRKS_NAME
    RS.Fields("WORKSTATION TYPE")= WRKS_TYPE
    RS.Fields("SERIAL NUMBER")= SERIAL_NUM
    RS.Fields("LOCATION")= LOCATION
    RS.Fields("DEPARTMENT")= DEPARTMENT
    RS.Fields("PROCESSOR")= PROCESSOR

    rs.Update
    rstemp.Close
    set rstemp=nothing
    response.redirect "inventory1.asp"
    %>

    There is no error, but no record is add. Did I do something wrong here?

    Thanks

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    51

    Post

    I get the following error message after I comment out the 'on error

    Microsoft OLE DB Provider for ODBC Drivers error '80004005'

    [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'USER'.

    Any Ideas what this error mean?



  4. #4
    Hyperactive Member
    Join Date
    Feb 2000
    Posts
    284

    Post

    You have the word 'User' a number of times in your code so set a breakpoint and step through the code with F8 to see where it is falling down.....It could be something quite simple like your User needs to be in quotes.

Posting Permissions

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



Click Here to Expand Forum to Full Width