|
 |
access_asp thread: Updating Database
Message #1 by "Robert Boczkay" <rboczkay@e...> on Tue, 23 Jul 2002 14:09:29
|
|
I am trying to update a access database with an asp page that gets an ID
from a previous page .asp?ID=a1b2c3 and then uses that ID as the criteria
of which record to update. The ID is made up of 6 letters and/or
numbers. The part that is not working is that page that it is forwarded
to. I have tried many things but now it says there are "too few
arguments. Expected 1 at the rsdatabase.Open strSQL, adoCon line. Here
is the code for the affected page. ID is the ID when submitted. NETID is
the actual ID field in the database table:
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsdatabase 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim RecordNo 'Holds the record number to be updated
'Read in the record number to be updated
RecordNo = Request.QueryString("ID")
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less
connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("\rboczkay\db\database.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=database"
'Create an ADO recordset object
Set rsdatabase = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT Master_List.* FROM Master_List WHERE NETID =" & RecordNo
'Open the recordset with the SQL query
rsdatabase.Open strSQL, adoCon
%>
<form name="form" method="post" action="update_entry.asp">
LAST NAME: <input type="text" name="LASTNAME" maxlength="20" value="<%
= rsdatabase("LASTNAME") %>">
<br>
FIRST NAME: <input type="text" name="FIRSTNAME" maxlength="60"
value="<% = rsdatabase("FIRSTNAME") %>">
<input type="hidden" name="NETID" value="<% = rsdatabase("NETID") %>">
<input type="submit" name="Submit" value="Submit">
</form>
<%
'Reset server objects
rsdatabase.Close
Set rsdatabase = Nothing
Set adoCon = Nothing
%>
Message #2 by Jon Sidnell <jon.sidnell@b...> on Tue, 23 Jul 2002 13:58:17 +0100
|
|
Robert
I've done a similar thing with passing ID codes through the URL. I've just
checked the code of a page that works, and the only difference I can see is
that you haven't put the Querystring through the Trim() function. This would
make your line be:
RecordNo = Trim(Request.QueryString("ID"))
Hope this helps
Jon
-----Original Message-----
From: Robert Boczkay [mailto:rboczkay@e...]
Sent: 23 July 2002 15:09
To: Access ASP
Subject: [access_asp] Updating Database
I am trying to update a access database with an asp page that gets an ID
from a previous page .asp?ID=a1b2c3 and then uses that ID as the criteria
of which record to update. The ID is made up of 6 letters and/or
numbers. The part that is not working is that page that it is forwarded
to. I have tried many things but now it says there are "too few
arguments. Expected 1 at the rsdatabase.Open strSQL, adoCon line. Here
is the code for the affected page. ID is the ID when submitted. NETID is
the actual ID field in the database table:
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsdatabase 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim RecordNo 'Holds the record number to be updated
'Read in the record number to be updated
RecordNo = Request.QueryString("ID")
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less
connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("\rboczkay\db\database.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=database"
'Create an ADO recordset object
Set rsdatabase = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT Master_List.* FROM Master_List WHERE NETID =" & RecordNo
'Open the recordset with the SQL query
rsdatabase.Open strSQL, adoCon
%>
<form name="form" method="post" action="update_entry.asp">
LAST NAME: <input type="text" name="LASTNAME" maxlength="20" value="<%
= rsdatabase("LASTNAME") %>">
<br>
FIRST NAME: <input type="text" name="FIRSTNAME" maxlength="60"
value="<% = rsdatabase("FIRSTNAME") %>">
<input type="hidden" name="NETID" value="<% = rsdatabase("NETID") %>">
<input type="submit" name="Submit" value="Submit">
</form>
<%
'Reset server objects
rsdatabase.Close
Set rsdatabase = Nothing
Set adoCon = Nothing
%>
This message and any attachments (the "message") are intended solely
for the addressees and are confidential. If you receive this message
in error, please delete it and immediately notify the sender.
Any use not in accord with its purpose, any dissemination or
disclosure, either whole or partial, is prohibited except formal
approval.
The internet can not guarantee the integrity of this message.
BNP PARIBAS LEASE GROUP PLC (and its subsidiaries)
shall (will) not therefore be liable for the message if modified.
Message #3 by "Robert Boczkay" <rboczkay@e...> on Tue, 23 Jul 2002 14:28:22
|
|
Nope, I still get:
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/rboczkay/BrinksterExamples/update.asp, line 27
It has to be something with the SELECT line that is causing this...anyone?
Message #4 by Jon Sidnell <jon.sidnell@b...> on Tue, 23 Jul 2002 14:19:14 +0100
|
|
If your ID is alpha-numeric and not just numeric, you need to put quote
marks around your actual value for NETID, making the line:
strSQL = "SELECT Master_List.* FROM Master_List WHERE NETID ='" & RecordNo &
"';"
Might be it
Jon
-----Original Message-----
From: Robert Boczkay [mailto:rboczkay@e...]
Sent: 23 July 2002 15:28
To: Access ASP
Subject: [access_asp] RE: Updating Database
Nope, I still get:
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/rboczkay/BrinksterExamples/update.asp, line 27
It has to be something with the SELECT line that is causing this...anyone?
This message and any attachments (the "message") are intended solely
for the addressees and are confidential. If you receive this message
in error, please delete it and immediately notify the sender.
Any use not in accord with its purpose, any dissemination or
disclosure, either whole or partial, is prohibited except formal
approval.
The internet can not guarantee the integrity of this message.
BNP PARIBAS LEASE GROUP PLC (and its subsidiaries)
shall (will) not therefore be liable for the message if modified.
Message #5 by "Robert Boczkay" <rboczkay@e...> on Tue, 23 Jul 2002 14:37:32
|
|
I love you! :-)
I am a newbie ASP person but not programmer and I thank you for the
help!!!!!!!!!
Rob
|
|
 |