Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Apr 2003
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    adding record to access problems

    I was wondering if anyone could help me with advice on this problem. I keep on looking at it and just can't see where the error is coming from or what it is trying to tell me

    I am using a access database and am getting this error when i am trying to add a record to this database

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

    The conection file i am using is:

    <% dim DRV, DBQ, CS , oC , oRS, oRS1, oCM
    DRV = "Driver={Microsoft Access Driver (*.mdb)}; "
    DBQ = "DBQ= C:\GWIT\product.mdb; "
    CS = DRV & DBQ
    set oC = server.createobject("ADODB.connection")
    set oCM = server.createobject("ADODB.Command")
    %>

    and the code i am using to add a new record is as below the error is stating it is at this part of the code oCM.Execute sql

    Dim sql
    sql = "INSERT INTO tblCustomer"
    sql = sql & "(CustFName, CustLName, CustState ,CustCountry ,CustEmail, CustRSize, CustRNum ,CustAdult, CustChild, CustCheckIn, CustCheckOut, CustHighFloor, CustBaby, CustFoldbed, CustPrice)"
    sql=sql & " VALUES "
    sql=sql & "('" & session.contents("name") & "',"
    sql=sql & "'" & session.contents("Lname") & "',"
    sql=sql & "'" & session.contents("state") & "',"
    sql=sql & "'" & session.contents("country") & "',"
    sql=sql & "'" & session.contents("email") & "',"
    sql=sql & "'" & session.contents("roomsize") & "',"
    sql=sql & "'" & session.contents("roomnum") & "',"
    sql=sql & "'" & session.Contents("adult") & "',"
    sql=sql & "'" & session.Contents("child") & "',"
    sql=sql & "'" & session.Contents("checkIn") & "',"
    sql=sql & "'" & session.Contents("checkOut") & "',"
    sql=sql & "'" & session.Contents("highfloor") & "',"
    sql=sql & "'" & session.Contents("baby") & "',"
    sql=sql & "'" & session.Contents("foldbed") & "',"
    sql=sql & "'" & session.Contents("price") & "')"


    oC.open CS
    oCM.ActiveConnection = oC
    oCM.CommandText = sql
    oCM.Execute sql
    %>

    Any help would be appreciated as i am really stumped
    Thanks

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you check that the file is not read only and that it's located in a directory where you have write rights on ?

  • #3
    New Coder
    Join Date
    Apr 2003
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I Have checked the file isn't read only and the yes the file path is correct and i definally have write rights on this file.

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, if you are sure it's not a permission issue, then check this thread.

    http://www.codingforums.com/showthre...ight=operation

    I've gotten the same error after copying the mdb files from one machine to another. Maybe try the fix i explain there (copy it to another name, remove original db and rename the copy to the original filename)

  • #5
    New Coder
    Join Date
    Apr 2003
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay did that copied the db and removed the original one then renamed the copy

    I managed to get rid of that error but i now have this error

    Which i know when you are working locally means you are trying to use your asp page when you have your access database open
    but that isn't the case this time

    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xa28 Thread 0xd30 DBC 0x14e2434 Jet'.


    Thanks for all you help so far it is much appreciated
    Last edited by carol; 10-12-2003 at 11:37 AM.

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's better to use a virtual and relative path, instead of a real path.

    Try using a connectionstring like
    Code:
    dim conn
    set conn=server.CreateObject("adodb.connection")
    conn.Open("provider=microsoft.jet.oledb.4.0;data source="& Request.ServerVariables("APPL_PHYSICAL_PATH") & "GWIT/product.mdb")
    the "GWIT/product.mdb" is the path from the applications root.

    I never had that error, and i don't see why you should get an error if your access db is opn. You can have more then 1 simultanious user for access so ...

  • #7
    New Coder
    Join Date
    Apr 2003
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i am really have lousy luck today

    okay i have got this error now

    ADODB.Command (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another

    I am starting to wonder if this is just one of those xp kinks that come with asp

    I might try it on a different system and see if that helps

  • #8
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On what line is the error ?
    It's not an XP problem.

    Also, if you used the connectionstring i posted, you don't need the

    oC.open CS
    oCM.ActiveConnection = oC

    Like
    Code:
    dim conn, sql, numinserted
    set conn=server.CreateObject("adodb.connection")
    conn.Open("provider=microsoft.jet.oledb.4.0;data source="& Request.ServerVariables("APPL_PHYSICAL_PATH") & "GWIT/product.mdb")
    
    sql = "INSERT INTO tblCustomer"
    sql = sql & "(CustFName, CustLName, CustState ,CustCountry ,CustEmail, CustRSize, CustRNum ,CustAdult, CustChild, CustCheckIn, CustCheckOut, CustHighFloor, CustBaby, CustFoldbed, CustPrice)"
    sql=sql & " VALUES "
    sql=sql & "('" & session.contents("name") & "',"
    sql=sql & "'" & session.contents("Lname") & "',"
    sql=sql & "'" & session.contents("state") & "',"
    sql=sql & "'" & session.contents("country") & "',"
    sql=sql & "'" & session.contents("email") & "',"
    sql=sql & "'" & session.contents("roomsize") & "',"
    sql=sql & "'" & session.contents("roomnum") & "',"
    sql=sql & "'" & session.Contents("adult") & "',"
    sql=sql & "'" & session.Contents("child") & "',"
    sql=sql & "'" & session.Contents("checkIn") & "',"
    sql=sql & "'" & session.Contents("checkOut") & "',"
    sql=sql & "'" & session.Contents("highfloor") & "',"
    sql=sql & "'" & session.Contents("baby") & "',"
    sql=sql & "'" & session.Contents("foldbed") & "',"
    sql=sql & "'" & session.Contents("price") & "')"
    
    numinserted = 0
    conn.Execute sql, numinserted
    numinserted will contain the number of inserted records (normally 1) so you can check if the insert was executed correctly like
    Code:
    conn.Execute sql, numinserted
    
    if numinserted <> 1 then
      response.write("Databaseproblem")
    else
      rest of your code
    end if

  • #9
    New Coder
    Join Date
    Apr 2003
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    okay tryed all that

    but am back to the same error i originally had

    Microsoft JET Database Engine (0x80004005)
    Operation must use an updateable query.


    conn.Execute sql, numinserted

    maybe access is corrupt and needs reseting up

    thats of your help is great appreciated


  •  

    Posting Permissions

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