This message was discovered on ASPFriends.com 'aspngibuyspy' list.
|
This is definitely a newbie question, but being a newbie to .net, I'm probably in good company. (grin)
I installed the ibuyspy portal successfully on my development server, and everything seems to work wonderfully, unitl I attempt to edit or add a user in the Admin Tab. When I do, I receive the following error message:
************* Begin Paste ************************ Server Error in '/PortalVB' Application. --------------------------------------------------------------------------- -----
Invalid attempt to read when no data is present. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.
Source Error:
Line 178: dr.Read() Line 179: Line 180: Email.Text = CStr(dr("Email")) Line 181: Password.Text = CStr(dr("Password")) Line 182:
Source File: G:\PortalVB\PortalVB\Admin\ManageUsers.aspx Line: 180
Stack Trace:
[InvalidOperationException: Invalid attempt to read when no data is present.] System.Data.SqlClient.SqlDataReader.PrepareRecord(Int32 i) +184 System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) +27 System.Data.SqlClient.SqlDataReader.get_Item(String name) +20 ASP.ManageUsers_aspx.BindData() in G:\PortalVB\PortalVB\Admin\ManageUsers.aspx:180 ASP.ManageUsers_aspx.Page_Load(Object Sender, EventArgs e) in G:\PortalVB\PortalVB\Admin\ManageUsers.aspx:74 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +29 System.Web.UI.Page.ProcessRequestMain() +724
--------------------------------------------------------------------------- ----- Version Information: Microsoft .NET Framework Version:1.0.3705.209; ASP.NET Version:1.0.3705.272
**************** End Paste ************************
The Querystring sent to the allplication is as follows: http://localhost/PortalVB/Admin/ManageUsers.aspx? userId=3&username=Click here to reveal e-mail address&tabindex=5&tabid=6
If anyone has any ideas as to why this error occurs out of the box, as it were, I'd love to hear it.
Thanks in advance.
The CodeSlicer
|
|
| |
| |
| Mike Sinclair |
If Click here to reveal e-mail address does indeed exist in the database there would have been info in the datareader. It seems a little strange that the user showed up in your dropdown list to select in the first place.
As it stands it looks like that particular user Click here to reveal e-mail address isn't in the database, because your not getting anything in your datareader. A simple solution would be to use:
If dr.Read() Then
Email.Text = CStr(dr("Email")) Password.Text = CStr(dr("Password"))
Else
Have something here to print to a label or something saying that this user could not be found. eg.
lblErrorMessage = "User could not be found"
End If
dr.Close()
At least that will stop your application from erroring.
Other than that you could look to see if the function in Security.vb looks like this:
Public Function GetSingleUser(ByVal email As String) As SqlDataReader
' Create Instance of Connection and Command Object Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("connectionString")) Dim myCommand As New SqlCommand("GetSingleUser", myConnection)
' Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC Dim parameterEmail As New SqlParameter("@Email", SqlDbType.NVarChar, 100) parameterEmail.Value = email myCommand.Parameters.Add(parameterEmail)
' Open the database connection and execute the command myConnection.Open() Dim dr As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' Return the datareader Return dr
End Function
Then check to see if the GetSingleUser Stored Procedure looks like this:
CREATE PROCEDURE GetSingleUser ( @Email nvarchar(100) ) AS SELECT Email, Password, Name FROM Users WHERE Email = @Email
GO
Actually now that I write this I vaguely remember a stored procedure missing from the portal when I first installed mine, and the GetSingleUser might be the one. So if you can't find the GetSingleUser Stored Procedure just create one using the code above.
Other than that I'm stumped.
Good luck!
-----Original Message----- From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address] Sent: Saturday, August 17, 2002 6:36 PM To: aspngibuyspy Subject: [aspngibuyspy] Error when adding or editing users
This is definitely a newbie question, but being a newbie to .net, I'm probably in good company. (grin)
I installed the ibuyspy portal successfully on my development server, and everything seems to work wonderfully, unitl I attempt to edit or add a user in the Admin Tab. When I do, I receive the following error message:
************* Begin Paste ************************ Server Error in '/PortalVB' Application. --------------------------------------------------------------------------- -----
Invalid attempt to read when no data is present. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.
Source Error:
Line 178: dr.Read() Line 179: Line 180: Email.Text = CStr(dr("Email")) Line 181: Password.Text = CStr(dr("Password")) Line 182:
Source File: G:\PortalVB\PortalVB\Admin\ManageUsers.aspx Line: 180
Stack Trace:
[InvalidOperationException: Invalid attempt to read when no data is present.] System.Data.SqlClient.SqlDataReader.PrepareRecord(Int32 i) +184 System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) +27 System.Data.SqlClient.SqlDataReader.get_Item(String name) +20 ASP.ManageUsers_aspx.BindData() in G:\PortalVB\PortalVB\Admin\ManageUsers.aspx:180 ASP.ManageUsers_aspx.Page_Load(Object Sender, EventArgs e) in G:\PortalVB\PortalVB\Admin\ManageUsers.aspx:74 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +29 System.Web.UI.Page.ProcessRequestMain() +724
--------------------------------------------------------------------------- ----- Version Information: Microsoft .NET Framework Version:1.0.3705.209; ASP.NET Version:1.0.3705.272
**************** End Paste ************************
The Querystring sent to the allplication is as follows: http://localhost/PortalVB/Admin/ManageUsers.aspx?userId=3&username=Admn@ibuy spy.com&tabindex=5&tabid=6
If anyone has any ideas as to why this error occurs out of the box, as it were, I'd love to hear it.
Thanks in advance.
The CodeSlicer
| [aspngibuyspy] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngibuyspy.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
|
|
| |
|
| |
|
The user does exist in the DB, and the code you provided looks to be in place in both the SQL database and in the aspx pages. As I said, being new to .net isn't helping here.
I've been coding in asp classic and VBScript since 1996, and all the code "Looks" right. justs won't allow me to add or edit a user from the admin Tab. It WILL allow a user to sign up, and I can delete the users, so it has to be somewhere in the ModifyUser pages....
If Click here to reveal e-mail address does indeed exist in the database there would have been info in the datareader. It seems a little strange that the user showed up in your dropdown list to select in the first place.
As it stands it looks like that particular user Click here to reveal e-mail address isn't in the database, because your not getting anything in your datareader. A simple solution would be to use:
If dr.Read() Then
Email.Text = CStr(dr("Email")) Password.Text = CStr(dr("Password"))
Else
Have something here to print to a label or something saying that this user could not be found. eg.
lblErrorMessage = "User could not be found"
End If
dr.Close()
At least that will stop your application from erroring.
Other than that you could look to see if the function in Security.vb looks like this:
Public Function GetSingleUser(ByVal email As String) As SqlDataReader
' Create Instance of Connection and Command Object Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("connectionString")) Dim myCommand As New SqlCommand("GetSingleUser", myConnection)
' Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC Dim parameterEmail As New SqlParameter("@Email", SqlDbType.NVarChar, 100) parameterEmail.Value = email myCommand.Parameters.Add(parameterEmail)
' Open the database connection and execute the command myConnection.Open() Dim dr As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' Return the datareader Return dr
End Function
Then check to see if the GetSingleUser Stored Procedure looks like this:
CREATE PROCEDURE GetSingleUser ( @Email nvarchar(100) ) AS SELECT Email, Password, Name FROM Users WHERE Email = @Email
GO
Actually now that I write this I vaguely remember a stored procedure missing from the portal when I first installed mine, and the GetSingleUser might be the one. So if you can't find the GetSingleUser Stored Procedure just create one using the code above.
Other than that I'm stumped.
Good luck!
-----Original Message----- From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address] Sent: Saturday, August 17, 2002 6:36 PM To: aspngibuyspy Subject: [aspngibuyspy] Error when adding or editing users
This is definitely a newbie question, but being a newbie to .net, I'm probably in good company. (grin)
I installed the ibuyspy portal successfully on my development server, and everything seems to work wonderfully, unitl I attempt to edit or add a user in the Admin Tab. When I do, I receive the following error message:
************* Begin Paste ************************ Server Error in '/PortalVB' Application. --------------------------------------------------------------------------- -----
Invalid attempt to read when no data is present. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.
Source Error:
Line 178: dr.Read() Line 179: Line 180: Email.Text = CStr(dr("Email")) Line 181: Password.Text = CStr(dr("Password")) Line 182:
Source File: G:\PortalVB\PortalVB\Admin\ManageUsers.aspx Line: 180
Stack Trace:
[InvalidOperationException: Invalid attempt to read when no data is present.] System.Data.SqlClient.SqlDataReader.PrepareRecord(Int32 i) +184 System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) +27 System.Data.SqlClient.SqlDataReader.get_Item(String name) +20 ASP.ManageUsers_aspx.BindData() in G:\PortalVB\PortalVB\Admin\ManageUsers.aspx:180 ASP.ManageUsers_aspx.Page_Load(Object Sender, EventArgs e) in G:\PortalVB\PortalVB\Admin\ManageUsers.aspx:74 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +29 System.Web.UI.Page.ProcessRequestMain() +724
--------------------------------------------------------------------------- ----- Version Information: Microsoft .NET Framework Version:1.0.3705.209; ASP.NET Version:1.0.3705.272
**************** End Paste ************************
The Querystring sent to the allplication is as follows: http://localhost/PortalVB/Admin/ManageUsers.aspx? userId=3&username=Admn@ibuy spy.com&tabindex=5&tabid=6
If anyone has any ideas as to why this error occurs out of the box, as it were, I'd love to hear it.
Thanks in advance.
The CodeSlicer
|
|
| |
|
| |
| Jon Elling |
Jerry,
Are you using Windows authentication? If so, when you go to the modification page the username to modify is being passed in the querystring, however, since the window's login is in the format "DOMAIN\user" the user name is getting maimed because it has a "\" in it. Since the username is screwed up the portal subsequently can't find an email entry or whatnot for that account. What you want to do is put a Server.URLEncode around the userid name from the page that calls the modification page.
This should get you started in the right direction. I hacked my code a bit to make modifying windows user's a bit smoother, so if you want that just holler.
Jon Elling
-----Original Message----- From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address] Sent: Sunday, August 18, 2002 10:41 AM To: aspngibuyspy Subject: [aspngibuyspy] RE: Error when adding or editing users
The user does exist in the DB, and the code you provided looks to be in place in both the SQL database and in the aspx pages. As I said, being new to .net isn't helping here.
I've been coding in asp classic and VBScript since 1996, and all the code "Looks" right. justs won't allow me to add or edit a user from the admin Tab. It WILL allow a user to sign up, and I can delete the users, so it has to be somewhere in the ModifyUser pages....
If Click here to reveal e-mail address does indeed exist in the database there would have been info in the datareader. It seems a little strange that the user showed up in your dropdown list to select in the first place.
As it stands it looks like that particular user Click here to reveal e-mail address isn't in the database, because your not getting anything in your datareader. A simple solution would be to use:
If dr.Read() Then
Email.Text = CStr(dr("Email")) Password.Text = CStr(dr("Password"))
Else
Have something here to print to a label or something saying that this user could not be found. eg.
lblErrorMessage = "User could not be found"
End If
dr.Close()
At least that will stop your application from erroring.
Other than that you could look to see if the function in Security.vb looks like this:
Public Function GetSingleUser(ByVal email As String) As SqlDataReader
' Create Instance of Connection and Command Object Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("connectionString")) Dim myCommand As New SqlCommand("GetSingleUser", myConnection)
' Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC Dim parameterEmail As New SqlParameter("@Email", SqlDbType.NVarChar, 100) parameterEmail.Value = email myCommand.Parameters.Add(parameterEmail)
' Open the database connection and execute the command myConnection.Open() Dim dr As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' Return the datareader Return dr
End Function
Then check to see if the GetSingleUser Stored Procedure looks like this:
CREATE PROCEDURE GetSingleUser ( @Email nvarchar(100) ) AS SELECT Email, Password, Name FROM Users WHERE Email = @Email
GO
Actually now that I write this I vaguely remember a stored procedure missing from the portal when I first installed mine, and the GetSingleUser might be the one. So if you can't find the GetSingleUser Stored Procedure just create one using the code above.
Other than that I'm stumped.
Good luck!
-----Original Message----- From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address] Sent: Saturday, August 17, 2002 6:36 PM To: aspngibuyspy Subject: [aspngibuyspy] Error when adding or editing users
This is definitely a newbie question, but being a newbie to .net, I'm probably in good company. (grin)
I installed the ibuyspy portal successfully on my development server, and everything seems to work wonderfully, unitl I attempt to edit or add a user in the Admin Tab. When I do, I receive the following error message:
************* Begin Paste ************************ Server Error in '/PortalVB' Application. --------------------------------------------------------------------------- -----
Invalid attempt to read when no data is present. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.
Source Error:
Line 178: dr.Read() Line 179: Line 180: Email.Text = CStr(dr("Email")) Line 181: Password.Text = CStr(dr("Password")) Line 182:
Source File: G:\PortalVB\PortalVB\Admin\ManageUsers.aspx Line: 180
Stack Trace:
[InvalidOperationException: Invalid attempt to read when no data is present.] System.Data.SqlClient.SqlDataReader.PrepareRecord(Int32 i) +184 System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) +27 System.Data.SqlClient.SqlDataReader.get_Item(String name) +20 ASP.ManageUsers_aspx.BindData() in G:\PortalVB\PortalVB\Admin\ManageUsers.aspx:180 ASP.ManageUsers_aspx.Page_Load(Object Sender, EventArgs e) in G:\PortalVB\PortalVB\Admin\ManageUsers.aspx:74 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +29 System.Web.UI.Page.ProcessRequestMain() +724
--------------------------------------------------------------------------- ----- Version Information: Microsoft .NET Framework Version:1.0.3705.209; ASP.NET Version:1.0.3705.272
**************** End Paste ************************
The Querystring sent to the allplication is as follows: http://localhost/PortalVB/Admin/ManageUsers.aspx? userId=3&username=Admn@ibuy spy.com&tabindex=5&tabid=6
If anyone has any ideas as to why this error occurs out of the box, as it were, I'd love to hear it.
Thanks in advance.
The CodeSlicer
| [aspngibuyspy] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngibuyspy.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
|
|
| |
|
| |
|
I had a similar problem - but I only noticed it after I had created a cookie to store the UserName (the setauthcookie only stores the user email).
Throughout the IBS code, the terms UserID, UserName, etc. are used inconsistently. When I added a cookie for "UserName", I got the same error as you did. When I walked through the debugger, I found that the UserName field in the ManageUsers.aspx (line 56) was actually filled with both the UserEmail (which was stored in the URL query string using the parameter UserName) AND the value in my UserName cookie!!! Obviously, the lookup in the data base then fails.
I changed the references throughout the ManageUsers code from UserName to UserEmail (to more accurately reflect what's happing) and the associated references in the users.ascx page (in the EditUser_Click) method. This fixed the problem and cleaned up the code IMHO.
I could of also fixed the problem by changing the request.params method in line 56 to the request.querystring method. The params method returns a collection of cookies, querystrings, server variables, and forms with the same name!
Your problem is after a clean install - however. I recommend you run the debugger with a stop on line 56 in ManageUsers.aspx and check the value of the UserName field after the line is executed. I suspect it's not what you think and will help identify the problem.
Mike Beller
<Click here to reveal e-mail address> wrote in message news:699447@aspngibuyspy... [Original message clipped]
|
|
| |
|
|
|
|
|