editing record in access database

editing record in access database

Post by Tim Midget » Fri, 11 Jul 2003 05:45:03


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 http://www.yqcomputer.com/
 
 
 

editing record in access database

Post by Mark Schup » Fri, 11 Jul 2003 08:48:05

. 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

"Tim Midgett" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
well)
Server.MapPath("ccalls.mdb")
=rsedit("date") %>">
=rsedit("time") %>">
type="radio" name="operator" value="John">Scott<input type="radio"
name="operator" value="Scott" value=<% =rsedit("operator") %>">
value=<% =rsedit("fname") %>">
value=<% =rsedit("initial") %>">
=rsedit("lname") %>">
=rsedit("ssn") %>">
value=<% =rsedit("account") %>">
=rsedit("deposit") %>">
=rsedit("address") %>">
value=<% =rsedit("direct") %>">
=rsedit("phone") %>">
value=<% =rsedit("phone") %>">></textarea>



 
 
 

editing record in access database

Post by Tim Midget » Sat, 12 Jul 2003 00:17:48


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 http://www.yqcomputer.com/ ***
Don't just participate in USENET...get rewarded for it!
 
 
 

editing record in access database

Post by Mark Schup » Sat, 12 Jul 2003 00:41:29

ou 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

"Tim Midgett" < XXXX@XXXXX.COM > wrote in message
news:% XXXX@XXXXX.COM ...


 
 
 

editing record in access database

Post by Tim Midget » Sat, 12 Jul 2003 01:08:12

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 http://www.yqcomputer.com/ ***
Don't just participate in USENET...get rewarded for it!