Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2004
    Posts
    4

    Unhappy Unanswered: Help!! Can't UPDATE Access DB using Ado!

    Hi @ll!

    I'm new at ADO and I'm trying to learn about it. I solved some problems already but I really don't know what to do about this one.

    This is the problem. I've created a simple asp page with this code:

    <!-- #INCLUDE file="functions.inc" -->
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <p>
    <% AddProd %>
    </body>
    </html>

    And the function:

    <% Sub AddProd()

    ' Get link info
    dim CatID
    CatID = Request.QueryString()

    dim Prod_Name, Prod_weigth, Prod_Units, Prod_Unit_Pr

    Prod_Name = Request.Form("prod_name")
    Prod_weigth = Request.Form("prod_weigth")
    Prod_Units = Request.Form("prod_units")
    Prod_Unit_Pr = Request.Form("prod_unit_pr")

    ' Setting ADO Connection
    set adoConn = server.createobject("adodb.connection")
    adoConn.Mode = adModeReadWrite
    adoConn.open connSrc

    ' Setting AddRs Recordset
    set AddRs = server.createobject("adodb.recordset")
    addRs.open "Products", adoConn, adOpenStatic, adLockPessimistic

    addRs.AddNew
    addRs("Product Name") = Prod_Name
    addRs("Product Weigth") = Prod_Weigth
    addRs("Product Name") = Prod_Units
    addRs("Product Name") = Prod_Unit_Pr
    addRs.Update

    'Cleanup Recordset
    addRs.close
    set addRs = nothing


    'Cleanup Connection
    adoConn.close
    set adoConn = nothing
    End Sub
    %>

    My browser returns the following error:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [Microsoft][Controlador Microsoft Access de ODBC] Update not possible. Database or object read-only.
    (translated from Portuguese)

    I'm running windows XP SP1 and IIS 5.1 and I created a DSN to my DB.

    What can I do to solve this problem?

    Hope someone can help me.

    Thank you @all very much,
    Pedro

  2. #2
    Join Date
    Dec 2003
    Posts
    454
    You may change adOpenStatic to adOpenDynamic.

  3. #3
    Join Date
    Jan 2004
    Posts
    4
    unfortunetly that didn't solve the problem...

    But thaks anyway,
    Pedro

  4. #4
    Join Date
    Dec 2003
    Posts
    454
    Did you try to insert data into a table on Query Analyzer?

  5. #5
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Err,... it's an Access Database, not a MS SQL database. Did you try inserting the data directly into the table via Access? It could be that the file is marked as read only.

  6. #6
    Join Date
    Jan 2004
    Posts
    4
    I'me new at ASP/ADO but I'm sure that Access db is working fine...the problem happens when I try to update it's records from a ASP page using ADO...

    But thanks anyway,
    Pedro

  7. #7
    Join Date
    Dec 2003
    Posts
    454
    In your code

    adoConn.open connSrc

    what is "connSrc"?

    The code should be

    adoConn.Open "DSN=dsnName;UserID=userID;pwd=password"

    Which one do you use to access your database?

    SQL server authentication or Windows NT authentication?

  8. #8
    Join Date
    Jan 2004
    Posts
    4
    Thank you @ll folks!

    I managed to solve the problem on my own.

    By the way what I've done was to change my connSrc to DSN-Less connection.

    I saw somewhere that OBDC is obsolete so I changed to something like this:
    connSrc = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=somesource;"
    using OLEDB instead.

    This bringed me some other problems that I've managed to solve using Microsoft Knowledge base and configuring permissions on XP and IIS 5.1.

    Thanks again,
    Pedro

Posting Permissions

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