473,749 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
-------------------------------------------------------------------------
chooseUserToEdi t.asp

<!--#Include File="Connect.a sp" -->

<%
Set RS = Server.CreateOb ject("ADODB.Rec ordset")
RS.ActiveConnec tion = 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="updateUse rForm.asp?pid=< %=RS("Pnr")%>">
<%=RS("Pnr")% ></a>
</td>
<td width="200"><%= RS("FirstName") %> </td>
<td><%=RS("Last Name")%> </td>
</tr>
<%
RS.MoveNext
WEND
%>

<%
RS.Close
Con.Close
%>

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

<!--#Include File="Connect.a sp" -->

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

Pnumber = Request.Queryst ring("pid")

'Open the Recordset

Set RS = Server.CreateOb ject("ADODB.Rec ordset")
RS.ActiveConnec tion = 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>Up date User</title></head>
<body bgcolor="">

<form method="post" action="updateU ser.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.HTML Encode(Pnr)%>">
</td>
</tr>
<tr>
<td>
<b>First name:</b>
</td>
<td>
<input name="FirstName " size="20"
value = "<%=Server.HTML Encode(FirstNam e)%>">
</td>
</tr>
<tr>
<td>
<b>Last name:</b>
</td>
<td>
<input name="LastName"
size="20"
value = "<%=Server.HTML Encode(LastName )%>">
</td>
</tr>
<tr>
<td>
<b>User name:</b>
</td>
<td>
<input name="UserName"
size="20"
value = "<%=Server.HTML Encode(UserName )%>">
</td>
</tr>
<tr>
<td>
<b>Password:</b>
</td>
<td>
<input name="PassWord"
size="20" maxlength="20"
value = "<%=Server.HTML Encode(PassWord )%>">
</td>
</tr>
<tr>
<td>
<b>User type:</b>
</td>
<td>
<input name="UserType"
size="20" maxlength="20"
value = "<%=Server.HTML Encode(UserType )%>">
</td>
</tr>
<tr>
<td>
<b>Company:</b>
</td>
<td>
<input name="Company"
size="20" maxlength="20"
value = "<%=Server.HTML Encode(Company) %>">
</td>
</tr>
<tr>
<td colspan=2 align="right">
<input type="submit" value="Add User">
</td>
</tr>
</table>
</center>

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

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

<!--#Include File="Connect.a sp" -->

<%

' 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>Up date 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="lighty ellow">
<tr>
<td>
<%=FirstName% > was updated in the database
</td>
</tr>
</table>
</center>
<p>
<%
END IF
%>

<a href="updateUse rForm.asp">Upda te User</a>

</body>
</html>
---------------------------------------------------------------------------
Jul 19 '05 #1
3 4991
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*******@hotm ail.com> wrote in message
news:a5******** *************** ***@posting.goo gle.com...

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*******@hotm ail.com> wrote in message
news:a5******** *************** ***@posting.goo gle.com... 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
8249
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 My question is how do i grab that value (3) and then use it in a query.
2
2688
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 navigation bar in each page. <!--#include virtual="/includes/nav/top_nav.asp"-->
5
6698
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 & "<br>"%> Exp <%'Response.Write GrantID & "<br>"%>
4
1675
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 SqlConnection("server=111.111.111.111;uid=;pwd=;database=mdMuseumStore"); SqlDataAdapter myCommand = new SqlDataAdapter("Select Painting, Artist, Title, Description from tbManetPaintings Where Painting = '"Request.QueryString"'", myConnection);
5
1851
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 button is clicked, check to see if the record exists using input from a form. I want to pass that variable to the button click Sub because if it doesn't exist then the record is inserted and the user is directed to a different page. The variable I'm...
2
1666
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 sPage query string value, it returns myTargetpage.asp?qs=1 and clips the 2nd querystring value pair. Can someone help me construct a link so myPopUp.asp preserves the entire query string? I tried using the Server.HtmlEncode comand in "FAILED...
3
1986
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 the WEB site to mail to passing a variable from the WEB site to the ASPX web site to E-Mail to? Hope I explained this correctly. This is a response from another group. There was no way for you to know it, but this is a classic asp newsgroup....
5
1835
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 CNAME = 'MICROSOFT'" This does not work: Dim var as string
3
1543
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: myNewPage.aspx?myParam = 10
0
9388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6800
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.