editing record in access database

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default editing record in access database

    I am trying to pull a record into a form and then edit it. (not working to well)
    Hoping someone can show me a better way than this:

    <%
    option Explicit
    Dim adoCon
    Dim rsedit
    Dim strSQL
    Dim lngRecordNo


    lngRecordNo = CLng(Request.QueryString("ID"))

    Set adoCon = Server.CreateObject("ADODB.Connection")

    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("ccalls.mdb")

    Set rsedit = Server.CreateObject("ADODB.Recordset")

    strSQL = "SELECT calltable.* FROM calltable WHERE ID_no=" & lngRecordNo

    rsedit.Open strSQL, adoCon
    %>

    <html>
    <head>
    <title>Record Update Form</title>
    </head>
    <body bgcolor="white" text="black">
    <!-- Begin form code -->
    <form name="form" method="post" action="update_entry.asp">

    Date of Call: <input type="text" name="date" maxlength="20" value=<% =rsedit("date") %>">
    <br>
    Time of Call: <input type="text" name="time" maxlength="20" value=<% =rsedit("time") %>">
    <br>
    Operator: Tim<input type="radio" name="operator" value="Tim">John<input type="radio" name="operator" value="John">Scott<input type="radio" name="operator" value="Scott" value=<% =rsedit("operator") %>">
    <br>
    First Name: <input type="text" first name="fname" maxlength="20" value=<% =rsedit("fname") %>">
    <br>
    Middle Initial: <input type="text" name="initial" maxlength="20" value=<% =rsedit("initial") %>">
    <br>
    Last Name: <input type="text" name="lname" maxlength="20" value=<% =rsedit("lname") %>">
    <br>
    SS Number: <input type="text" name="ssn" maxlength="20" value=<% =rsedit("ssn") %>">
    <br>
    Account Number: <input type="text" name="account" maxlength="20" value=<% =rsedit("account") %>">
    <br>
    Last Deposit: <input type="text" name="deposit" maxlength="20" value=<% =rsedit("deposit") %>">
    <br>
    Home Address: <input type="text" name="address" maxlength="30" value=<% =rsedit("address") %>">
    <br>
    Direct Deposit From: <input type="text" name="direct" maxlength="30" value=<% =rsedit("direct") %>">
    <br>
    Phone Number: <input type="text" name="phone" maxlength="20" value=<% =rsedit("phone") %>">
    <br>
    Reason for the call: <textarea row="5" cols="49" name="reason" rows="4" value=<% =rsedit("phone") %>">></textarea>

    <input type="hidden" name="ID_no" value="<% = rsedit("ID_no") %>">
    <input type="submit" name="Submit" value="Submit">
    </form>
    <!-- End form code -->
    </body>
    </html>

    <%

    rsedit.Close
    Set rsedit = Nothing
    Set adoCon = Nothing
    %>

    That is what I have so far. I am not sure if I am even close.
    Thanks Tim

    -----------------------------
    This message is posted by [url]http://Asp.ForumsZone.com[/url]

    Tim Midgett Guest

  2. Similar Questions and Discussions

    1. Editing a record from a datagrid.
      I’m building a small application and I have to build it using asp.net, vb.net and my database is MSDE. I have a datagrid with a list of customers...
    2. problems adding record to access database
      Greetings I'm having problems adding records to an access database. What I want to do is very simple. Here is my code. __CODE_START__ dim...
    3. Trouble with database access: can't edit record, just view it
      Hallo! I use DWMX 6.1 and use ASP VBSCRIPT files to access a MS Access 2000 database. Initially I was able to edit the records. Then I had to add...
    4. deleting access database record
      I am trying to write an asp page to delete a record from my access database. I have written the page to display the info but when I select the entry...
    5. Need Web-Based DB Record Editing Tool
      Hi, all. Is anybody currently using a web-based tool to add/edit/delete records to SQL Server 2000 tables? I've been writing my own ADO.NET &...
  3. #2

    Default Re: editing record in access database

    1. Use connection.execute instead of recordset.open
    set rsedit = adocon.execute(strsql,,adcmdtext)
    2. List the columns in the sql statement instead of using "*"
    strsql = "select date,time,operator...
    3. Put quotes around your values and HTMLEncode them (it looks like you have
    trailing quotes but not starting quotes).
    value="<% =Server.HTMLEncode(rsedit("date"))%>"
    You may have some problems with null values.
    4. Use "view source" in the browser to see what the HTML actually looks
    like.

    --
    Mark Schupp
    --
    Head of Development
    Integrity eLearning
    Online Learning Solutions Provider
    [email]mschupp@ielearning.com[/email]
    [url]http://www.ielearning.com[/url]
    714.637.9480 x17


    "Tim Midgett" <tmidgett@unitedfidelity.com> wrote in message
    news:924867036058459@Asp.ForumsZone.com...
    > I am trying to pull a record into a form and then edit it. (not working to
    well)
    > Hoping someone can show me a better way than this:
    >
    > <%
    > option Explicit
    > Dim adoCon
    > Dim rsedit
    > Dim strSQL
    > Dim lngRecordNo
    >
    >
    > lngRecordNo = CLng(Request.QueryString("ID"))
    >
    > Set adoCon = Server.CreateObject("ADODB.Connection")
    >
    > adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
    Server.MapPath("ccalls.mdb")
    >
    > Set rsedit = Server.CreateObject("ADODB.Recordset")
    >
    > strSQL = "SELECT calltable.* FROM calltable WHERE ID_no=" & lngRecordNo
    >
    > rsedit.Open strSQL, adoCon
    > %>
    >
    > <html>
    > <head>
    > <title>Record Update Form</title>
    > </head>
    > <body bgcolor="white" text="black">
    > <!-- Begin form code -->
    > <form name="form" method="post" action="update_entry.asp">
    >
    > Date of Call: <input type="text" name="date" maxlength="20" value=<%
    =rsedit("date") %>">
    > <br>
    > Time of Call: <input type="text" name="time" maxlength="20" value=<%
    =rsedit("time") %>">
    > <br>
    > Operator: Tim<input type="radio" name="operator" value="Tim">John<input
    type="radio" name="operator" value="John">Scott<input type="radio"
    name="operator" value="Scott" value=<% =rsedit("operator") %>">
    > <br>
    > First Name: <input type="text" first name="fname" maxlength="20"
    value=<% =rsedit("fname") %>">
    > <br>
    > Middle Initial: <input type="text" name="initial" maxlength="20"
    value=<% =rsedit("initial") %>">
    > <br>
    > Last Name: <input type="text" name="lname" maxlength="20" value=<%
    =rsedit("lname") %>">
    > <br>
    > SS Number: <input type="text" name="ssn" maxlength="20" value=<%
    =rsedit("ssn") %>">
    > <br>
    > Account Number: <input type="text" name="account" maxlength="20"
    value=<% =rsedit("account") %>">
    > <br>
    > Last Deposit: <input type="text" name="deposit" maxlength="20" value=<%
    =rsedit("deposit") %>">
    > <br>
    > Home Address: <input type="text" name="address" maxlength="30" value=<%
    =rsedit("address") %>">
    > <br>
    > Direct Deposit From: <input type="text" name="direct" maxlength="30"
    value=<% =rsedit("direct") %>">
    > <br>
    > Phone Number: <input type="text" name="phone" maxlength="20" value=<%
    =rsedit("phone") %>">
    > <br>
    > Reason for the call: <textarea row="5" cols="49" name="reason" rows="4"
    value=<% =rsedit("phone") %>">></textarea>
    >
    > <input type="hidden" name="ID_no" value="<% = rsedit("ID_no") %>">
    > <input type="submit" name="Submit" value="Submit">
    > </form>
    > <!-- End form code -->
    > </body>
    > </html>
    >
    > <%
    >
    > rsedit.Close
    > Set rsedit = Nothing
    > Set adoCon = Nothing
    > %>
    >
    > That is what I have so far. I am not sure if I am even close.
    > Thanks Tim
    >
    > -----------------------------
    > This message is posted by [url]http://Asp.ForumsZone.com[/url]
    >

    Mark Schupp Guest

  4. #3

    Default Re: editing record in access database


    Thanks Mark, I tried it. I am getting the following wrror message now.

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E0C)
    Command text was not set for the command object.
    /edit.asp, line 16

    Here is the code that I entered:

    <%
    option Explicit
    Dim adoCon
    Dim rsedit
    Dim strSQL
    Dim lngRecordNo
    Dim adcmdtext

    lngRecordNo = CLng(Request.QueryString("ID"))

    Set adoCon = Server.CreateObject("ADODB.Connection")

    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
    Server.MapPath("ccalls.mdb")

    'Set rsedit = Server.CreateObject("ADODB.Recordset")
    set rsedit = adocon.execute(strsql,,adcmdtext)

    'strSQL = "SELECT calltable.* FROM calltable WHERE ID_no=" & lngRecordNo
    strsql = "select
    date,time,operator,fname,initial,lname,ssn,account ,deposit,address,direc
    t,reason"
    rsedit.Open strSQL, adoCon
    %>




    <html>
    <head>
    <title>Record Update Form</title>
    </head>
    <body bgcolor="white" text="black">
    <!-- Begin form code -->
    <form name="form" method="post" action="update_entry.asp">

    Date of Call: <input type="text" name="date" maxlength="20" value=<%
    =rsedit("date") %>">
    <br>
    Time of Call: <input type="text" name="time" maxlength="20" value=<%
    =rsedit("time") %>">
    <br>
    Operator: Tim<input type="radio" name="operator"
    value="Tim">John<input type="radio" name="operator"
    value="John">Scott<input type="radio" name="operator" value="Scott"
    value=<% =rsedit("operator") %>">
    <br>
    First Name: <input type="text" first name="fname" maxlength="20"
    value=<% =rsedit("fname") %>">
    <br>
    Middle Initial: <input type="text" name="initial" maxlength="20"
    value=<% =rsedit("initial") %>">
    <br>
    Last Name: <input type="text" name="lname" maxlength="20" value=<%
    =rsedit("lname") %>">
    <br>
    SS Number: <input type="text" name="ssn" maxlength="20" value=<%
    =rsedit("ssn") %>">
    <br>
    Account Number: <input type="text" name="account" maxlength="20"
    value=<% =rsedit("account") %>">
    <br>
    Last Deposit: <input type="text" name="deposit" maxlength="20"
    value=<% =rsedit("deposit") %>">
    <br>
    Home Address: <input type="text" name="address" maxlength="30"
    value=<% =rsedit("address") %>">
    <br>
    Direct Deposit From: <input type="text" name="direct" maxlength="30"
    value=<% =rsedit("direct") %>">
    <br>
    Phone Number: <input type="text" name="phone" maxlength="20" value=<%
    =rsedit("phone") %>">
    <br>
    Reason for the call: <textarea row="5" cols="49" name="reason"
    rows="4" value=<% =rsedit("phone") %>">></textarea>

    <input type="hidden" name="ID_no" value="<% = rsedit("ID_no") %>">
    <input type="submit" name="Submit" value="Submit">
    </form>
    <!-- End form code -->
    </body>
    </html>

    <%

    rsedit.Close
    Set rsedit = Nothing
    Set adoCon = Nothing
    %>

    Thanks Tim

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Tim Midgett Guest

  5. #4

    Default Re: editing record in access database

    you have to set strsql before the adocon.execute statement. then lose the
    rsedit.open statement. you also left out the from and where clause in the
    sql statement

    strsql = "select date, time, operator, fname, initial, lname, ssn, account,
    deposit, address, direct, reason FROM calltable WHERE ID_no=" & lngRecordNo
    set rsedit = adocon.execute(strsql,,adcmdtext)

    --
    Mark Schupp
    --
    Head of Development
    Integrity eLearning
    Online Learning Solutions Provider
    [email]mschupp@ielearning.com[/email]
    [url]http://www.ielearning.com[/url]
    714.637.9480 x17


    "Tim Midgett" <tmidgett@unitedfidelity.com> wrote in message
    news:%23DrJtZvRDHA.2196@TK2MSFTNGP11.phx.gbl...
    >
    > Thanks Mark, I tried it. I am getting the following wrror message now.
    >
    > Microsoft OLE DB Provider for ODBC Drivers (0x80040E0C)
    > Command text was not set for the command object.
    > /edit.asp, line 16
    >
    > Here is the code that I entered:
    >
    > <%
    > option Explicit
    > Dim adoCon
    > Dim rsedit
    > Dim strSQL
    > Dim lngRecordNo
    > Dim adcmdtext
    >
    > lngRecordNo = CLng(Request.QueryString("ID"))
    >
    > Set adoCon = Server.CreateObject("ADODB.Connection")
    >
    > adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
    > Server.MapPath("ccalls.mdb")
    >
    > 'Set rsedit = Server.CreateObject("ADODB.Recordset")
    > set rsedit = adocon.execute(strsql,,adcmdtext)
    >
    > 'strSQL = "SELECT calltable.* FROM calltable WHERE ID_no=" & lngRecordNo
    > strsql = "select
    > date,time,operator,fname,initial,lname,ssn,account ,deposit,address,direc
    > t,reason"
    > rsedit.Open strSQL, adoCon
    > %>
    >
    >
    >
    >
    > <html>
    > <head>
    > <title>Record Update Form</title>
    > </head>
    > <body bgcolor="white" text="black">
    > <!-- Begin form code -->
    > <form name="form" method="post" action="update_entry.asp">
    >
    > Date of Call: <input type="text" name="date" maxlength="20" value=<%
    > =rsedit("date") %>">
    > <br>
    > Time of Call: <input type="text" name="time" maxlength="20" value=<%
    > =rsedit("time") %>">
    > <br>
    > Operator: Tim<input type="radio" name="operator"
    > value="Tim">John<input type="radio" name="operator"
    > value="John">Scott<input type="radio" name="operator" value="Scott"
    > value=<% =rsedit("operator") %>">
    > <br>
    > First Name: <input type="text" first name="fname" maxlength="20"
    > value=<% =rsedit("fname") %>">
    > <br>
    > Middle Initial: <input type="text" name="initial" maxlength="20"
    > value=<% =rsedit("initial") %>">
    > <br>
    > Last Name: <input type="text" name="lname" maxlength="20" value=<%
    > =rsedit("lname") %>">
    > <br>
    > SS Number: <input type="text" name="ssn" maxlength="20" value=<%
    > =rsedit("ssn") %>">
    > <br>
    > Account Number: <input type="text" name="account" maxlength="20"
    > value=<% =rsedit("account") %>">
    > <br>
    > Last Deposit: <input type="text" name="deposit" maxlength="20"
    > value=<% =rsedit("deposit") %>">
    > <br>
    > Home Address: <input type="text" name="address" maxlength="30"
    > value=<% =rsedit("address") %>">
    > <br>
    > Direct Deposit From: <input type="text" name="direct" maxlength="30"
    > value=<% =rsedit("direct") %>">
    > <br>
    > Phone Number: <input type="text" name="phone" maxlength="20" value=<%
    > =rsedit("phone") %>">
    > <br>
    > Reason for the call: <textarea row="5" cols="49" name="reason"
    > rows="4" value=<% =rsedit("phone") %>">></textarea>
    >
    > <input type="hidden" name="ID_no" value="<% = rsedit("ID_no") %>">
    > <input type="submit" name="Submit" value="Submit">
    > </form>
    > <!-- End form code -->
    > </body>
    > </html>
    >
    > <%
    >
    > rsedit.Close
    > Set rsedit = Nothing
    > Set adoCon = Nothing
    > %>
    >
    > Thanks Tim
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Mark Schupp Guest

  6. #5

    Default Re: editing record in access database

    Thanks Mark, I have cleaned it up some it looks like this now:

    <%
    option Explicit
    Dim adoCon
    Dim rsedit
    Dim strSQL
    Dim lngRecordNo
    Dim adcmdtext

    lngRecordNo = CLng(Request.QueryString("ID"))

    Set adoCon = Server.CreateObject("ADODB.Connection")

    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
    Server.MapPath("ccalls.mdb")

    strsql = "select
    date,time,operator,fname,initial,lname,ssn,account ,deposit,address,direc
    t,reason FROM calltable WHERE ID_no=" & lngRecordNo

    set rsedit = adocon.execute(strsql,,adcmdtext)
    %>




    <html>
    <head>
    <title>Record Update Form</title>
    </head>
    <body bgcolor="white" text="black">
    <!-- Begin form code -->
    <form name="form" method="post" action="update_entry.asp">

    Date of Call: <input type="text" name="date" maxlength="20" value=<%
    =rsedit("date") %>">
    <br>
    Time of Call: <input type="text" name="time" maxlength="20" value=<%
    =rsedit("time") %>">
    <br>
    Operator: Tim<input type="radio" name="operator"
    value="Tim">John<input type="radio" name="operator"
    value="John">Scott<input type="radio" name="operator" value="Scott"
    value=<% =rsedit("operator") %>">
    <br>
    First Name: <input type="text" first name="fname" maxlength="20"
    value=<% =rsedit("fname") %>">
    <br>
    Middle Initial: <input type="text" name="initial" maxlength="20"
    value=<% =rsedit("initial") %>">
    <br>
    Last Name: <input type="text" name="lname" maxlength="20" value=<%
    =rsedit("lname") %>">
    <br>
    SS Number: <input type="text" name="ssn" maxlength="20" value=<%
    =rsedit("ssn") %>">
    <br>
    Account Number: <input type="text" name="account" maxlength="20"
    value=<% =rsedit("account") %>">
    <br>
    Last Deposit: <input type="text" name="deposit" maxlength="20"
    value=<% =rsedit("deposit") %>">
    <br>
    Home Address: <input type="text" name="address" maxlength="30"
    value=<% =rsedit("address") %>">
    <br>
    Direct Deposit From: <input type="text" name="direct" maxlength="30"
    value=<% =rsedit("direct") %>">
    <br>
    Phone Number: <input type="text" name="phone" maxlength="20" value=<%
    =rsedit("phone") %>">
    <br>
    Reason for the call: <textarea row="5" cols="49" name="reason"
    rows="4" value=<% =rsedit("phone") %>">></textarea>

    <input type="hidden" name="ID_no" value="<% = rsedit("ID_no") %>">
    <input type="submit" name="Submit" value="Submit">
    </form>
    <!-- End form code -->
    </body>
    </html>

    I am now getting an EOF error

    ADODB.Field (0x80020009)
    Either BOF or EOF is True, or the current record has been deleted.
    Requested operation requires a current record.
    /edit.asp

    Thanks Tim



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Tim Midgett Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139