Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Midland, Michigan, USA
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Call Access Function from ASP page

    You've heard the 'I know nothing about [ insert Product here ]' spiel before, so I won't give it...

    My brother is attempting to delete an Access database record from within an ASP page. He can successfully add/modify records, but cannot delete for some reason. My limited knowledge in Access/dangerous knowledge of the Access Object Model led me to create a function that will delete a record, but we cannot get the ASP page to call that function.

    I'll accept any advice - be it a slap on the wrist and a "<font color=red>do it this way</font color=red>" or a line to add to his ASP code - or web site you can offer, and will pass the info on to my brother.

    NOTE: It is a non-relational database -- it's just a single table, AFAIK.

    Let me know what glaringly-important information I've left out, and I'll get back to you. Thanks.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Call Access Function from ASP page

    I'll bet the problem lies in the Cursor type and/or Lock type arguments of the Recordset object. You need to use a Dynamic or Keyset cursor and anything but a Read only lock type.

    Here's an example of how to delete a record with ASP/ADO (the first line is necessary in order to use the ADO/VBScript constants - otherwise you would have to use numbers instead of constant names such as adOpenDynamic):


    <%
    set cnn = Server.CreateObject("ADODB.Connection")
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/db/MyDatabase.mdb") & ";",

    set rst = Server.CreateObject("ADODB.Recordset")
    rst.Open "SELECT * FROM tbl_Customers", cnn, adOpenKeyset, adLockOptimistic

    rst.MoveFirst
    rst.Find "CustomerID=" & lngCustomerID

    rst.Delete

    rst.Close
    set rst = nothing
    cnn.Close
    set cnn = nothing

    %>

    HTH

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Midland, Michigan, USA
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Call Access Function from ASP page

    Thanks. He has informed me that he will be recreating his ASP page from scratch. You'll probably hear from me in this forum in a couple of weeks.

Posting Permissions

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