473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

passing variable with querystring - update db - error !?

Hi folks !
got this problem...
i have a table 'Accounts' in my database, which contains a bunch of
users. From the main menu i choose "edit user" and all users in the db
are presented in a table. The first column 'Pnr' is a unique ID for
each user that i made appear as a link. clicking on one userID should
present a form where the picked users userdata is already filled in so
i can easily edit it and then move on to submit the form to update the
db. i get to the part where all users are listed nicely in a table,
but clicking on one, i get this error:

Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested
name or ordinal.
/VS_Files/updateUserForm.asp, line 19

I think i'm doing something wrong with passing a value with the
querystring...?
include the code below...

could really use some help...
appreciate it a lot...

Fredrik Holm
-------------------------------------------------------------------------
chooseUserToEdit.asp

<!--#Include File="Connect.asp" -->

<%
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = Con

SQLstring = "SELECT Pnr, FirstName, LastName FROM Accounts"
RS.Open SQLstring
%>

<html>
<body bgcolor="">

<center>
<table width="500" border=1 bgcolor=""
cellpadding="4" cellspacing="0">
<tr>
<td align="center" colspan="3" bgcolor="">
<font face="Arial" size="3"><b>
Choose user to edit
</b></font>
</td>
</tr>

<%
'loop through all available users & display them

WHILE NOT RS.EOF
%>
<tr>
<!--passes a querystring to updateUserForm.asp
matches href with right record -->

<td width="100"><a href="updateUserForm.asp?pid=<%=RS("Pnr")%>">
<%=RS("Pnr")%></a>
</td>
<td width="200"><%=RS("FirstName")%> </td>
<td><%=RS("LastName")%> </td>
</tr>
<%
RS.MoveNext
WEND
%>

<%
RS.Close
Con.Close
%>

</table>
</center>
</body>
</html>
------------------------------------------------------------------------
updateUserForm.asp

<!--#Include File="Connect.asp" -->

<%
'Get the user Pnr from chooseUserToEdit.asp (through the
querystring)

Pnumber = Request.Querystring("pid")

'Open the Recordset

Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = Con

SQLstring = "SELECT * FROM Accounts WHERE Pnr = " & "'" & Pnumber &
"'"
RS.Open SQLstring

'store the record in local variables

IF NOT RS.EOF THEN
Pnr = RS(" Pnr ")
FirstName = RS(" FirstName ")
LastName = RS(" LastName ")
UserName = RS(" UserName ")
PassWord = RS(" PassWord ")
UserType = RS(" UserType ")
Company = RS(" Company ")
END IF
RS.Close

%>

<html>
<head><title>Update User</title></head>
<body bgcolor="">

<form method="post" action="updateUser.asp">

<center>
<table width="600" border=1 bgcolor=""
cellpadding="4" cellspacing="0">
<tr>
<td colspan="2" bgcolor="">
<font face="Arial" size="3"><b>
Edit User
</b></font>
</td>
</tr>
<tr>
<td>
<b> Pnr:</b>
</td>
<td>
<input name="Pnr"
size="20" maxlength="20"
value = "<%=Server.HTMLEncode(Pnr)%>">
</td>
</tr>
<tr>
<td>
<b>First name:</b>
</td>
<td>
<input name="FirstName" size="20"
value = "<%=Server.HTMLEncode(FirstName)%>">
</td>
</tr>
<tr>
<td>
<b>Last name:</b>
</td>
<td>
<input name="LastName"
size="20"
value = "<%=Server.HTMLEncode(LastName)%>">
</td>
</tr>
<tr>
<td>
<b>User name:</b>
</td>
<td>
<input name="UserName"
size="20"
value = "<%=Server.HTMLEncode(UserName)%>">
</td>
</tr>
<tr>
<td>
<b>Password:</b>
</td>
<td>
<input name="PassWord"
size="20" maxlength="20"
value = "<%=Server.HTMLEncode(PassWord)%>">
</td>
</tr>
<tr>
<td>
<b>User type:</b>
</td>
<td>
<input name="UserType"
size="20" maxlength="20"
value = "<%=Server.HTMLEncode(UserType)%>">
</td>
</tr>
<tr>
<td>
<b>Company:</b>
</td>
<td>
<input name="Company"
size="20" maxlength="20"
value = "<%=Server.HTMLEncode(Company)%>">
</td>
</tr>
<tr>
<td colspan=2 align="right">
<input type="submit" value="Add User">
</td>
</tr>
</table>
</center>

<input name="updateUser" type="hidden" value="1">
</form>

</body>
</html>
-------------------------------------------------------------------
updateUser.asp

<!--#Include File="Connect.asp" -->

<%

' Get the Form Variables
updateUser = TRIM( Request( "updateUser" ) )

Pnr = TRIM( Request( "Pnr" ) )
FirstName = TRIM( Request( "FirstName" ) )
LastName = TRIM( Request( "LastName" ) )
UserName = TRIM( Request( "UserName" ) )
PassWord = TRIM( Request( "PassWord" ) )
UserType = TRIM( Request( "UserType" ) )
Company = TRIM( Request( "Company" ) )
' Assign Default Values
IF Pnr = "" THEN
Pnr = "???"
END IF
IF FirstName = "" THEN
FirstName = "???"
END IF
IF LastName = "" THEN
LastName = "???"
END IF
IF UserName = "" THEN
UserName = "???"
END IF
IF PassWord = "" THEN
PassWord = "???"
END IF
IF UserType = "" THEN
UserType = "???"
END IF
IF Company = "" THEN
Company = "???"
END IF

%>
<html>
<head><title>Update Users</title></head>
<body bgcolor="gray">
<%
' Update User
IF updateUser <> "" THEN

sqlString = "UPDATE Accounts SET Pnr = ' " & Pnr & "'," & "'" &
FirstName & "'," &_
"'" & LastName & "'," & "'" & UserName & "'," & "'" &
PassWord & "'," &_
"'" & UserType & "'," & "'" & Company & "'" &_
"WHERE Pnr = " & "'" & Pnr & "'"
Con.Execute sqlString
%>
<center>
<table width="600" cellpadding="4"
cellspacing="0" bgcolor="lightyellow">
<tr>
<td>
<%=FirstName%> was updated in the database
</td>
</tr>
</table>
</center>
<p>
<%
END IF
%>

<a href="updateUserForm.asp">Update User</a>

</body>
</html>
---------------------------------------------------------------------------
Jul 19 '05 #1
3 4951
My first guess is that it's because of your spaces. Is the column named "
Pnr" or "Pnr?"

Also, please read the following articles when you have free time.
http://www.aspfaq.com/2191
http://www.aspfaq.com/2096

Ray at work

"Fredrik/Sweden" <fr*******@hotmail.com> wrote in message
news:a5**************************@posting.google.c om...

Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested
name or ordinal.
/VS_Files/updateUserForm.asp, line 19

Pnr = RS(" Pnr ")

Jul 19 '05 #2
Perhaps change this:
Pnr = RS(" Pnr ")
FirstName = RS(" FirstName ")
LastName = RS(" LastName ")
UserName = RS(" UserName ")
PassWord = RS(" PassWord ")
UserType = RS(" UserType ")
Company = RS(" Company ")

To be this instead:
Pnr = RS("Pnr")
FirstName = RS("FirstName")
LastName = RS("LastName")
UserName = RS("UserName")
PassWord = RS("PassWord")
UserType = RS("UserType")
Company = RS("Company")

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

All of these field names have spaces around them. Fix that and it should be
fine (assuming that's the only error)
IF NOT RS.EOF THEN
Pnr = RS(" Pnr ")
FirstName = RS(" FirstName ")
LastName = RS(" LastName ")
UserName = RS(" UserName ")
PassWord = RS(" PassWord ")
UserType = RS(" UserType ")
Company = RS(" Company ")
END IF

Tim
"Fredrik/Sweden" <fr*******@hotmail.com> wrote in message
news:a5**************************@posting.google.c om... Hi folks !
got this problem...
i have a table 'Accounts' in my database, which contains a bunch of
users. From the main menu i choose "edit user" and all users in the db
are presented in a table. The first column 'Pnr' is a unique ID for
each user that i made appear as a link. clicking on one userID should
present a form where the picked users userdata is already filled in so
i can easily edit it and then move on to submit the form to update the
db. i get to the part where all users are listed nicely in a table,
but clicking on one, i get this error:

Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: alexz | last post by:
I'm redirecting a value to a page called update.asp from somepage.asp Recid = Request.QueryString("qryCategory") Response.redirect "update.asp?" & Recid So it shows like /update.asp?3 ...
2
by: John Aspinall | last post by:
Hi, Ive got a navigation bar for my web pages in an include (top_nav.asp). On my homepage (index.asp) and all the other site pages I have a reference to this include which includes my...
5
by: Jack | last post by:
Hi, I need to pass multple variables in a link in order to go to a asp page with the two varables. The following are the values of the variables using response.write: <%'Response.Write Mypage...
4
by: Vincent Jones | last post by:
in index.asp, i'm passing the this variable: <a href="Description.aspx?Painting=<%=RS2("Painting")%>">Painting</a> void Page_Load(Object sender, EventArgs e) { SqlConnection myConnection = new...
5
by: Jim via DotNetMonster.com | last post by:
Hi, I need to pass the value of a variable from one function to another but I don't seem to get the value. I declare the variable outside all functions. What I'm trying to do is that when the...
2
by: Scott | last post by:
I'm trying to create a link (SEE LINK BELOW) to a pop-up window (myPopUp.asp). My problem is my sTargetPage variable is a url containing a querystring variable. When myPopUp.asp opens and I get my...
3
by: James Robertson | last post by:
I am new to the ASP and VB thing so be kind. Question I have is that I have created an ASPX web site to use as an E-Mail page. But I want to use this for a lot of users. Can I create the link on...
5
by: glenn | last post by:
Hi folks, The problem I have is that a query string works if hard-coded but if I pass a variable to it, it does not work as shown here. This works: querystring="SELECT * FROM USERS WHERE...
3
by: Tor Inge Rislaa | last post by:
Passing and using parameters How to get hold of the parameter value provided by the URL? When I open a web form with a DataSource I often include a parameter in the URL as below: ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.