Click here to Skip to main content
15,887,683 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Custom Control Problem Pin
Christian Graus14-Apr-08 11:20
protectorChristian Graus14-Apr-08 11:20 
GeneralRe: Custom Control Problem Pin
DominionZA14-Apr-08 11:24
DominionZA14-Apr-08 11:24 
GeneralSimple but confusing ASP .NET /javascript question Pin
Mohammad A Gdeisat14-Apr-08 11:05
Mohammad A Gdeisat14-Apr-08 11:05 
GeneralRe: Simple but confusing ASP .NET /javascript question Pin
Christian Graus14-Apr-08 11:19
protectorChristian Graus14-Apr-08 11:19 
GeneralRe: Simple but confusing ASP .NET /javascript question Pin
Mohammad A Gdeisat14-Apr-08 11:38
Mohammad A Gdeisat14-Apr-08 11:38 
QuestionHow To Store a File in Database Using FileUpLoad web control Pin
ArunVijay14-Apr-08 7:49
ArunVijay14-Apr-08 7:49 
AnswerRe: How To Store a File in Database Using FileUpLoad web control Pin
Mark J. Miller14-Apr-08 8:37
Mark J. Miller14-Apr-08 8:37 
QuestionDataReader throws exception Pin
jamie21cor14-Apr-08 3:35
jamie21cor14-Apr-08 3:35 
Hi, I was wondering if anyone could help me with a DataTable problem. I am working in ASP.NET C#, The code that I have written is listed below. The moSqlDataReader can be viewed when in debug mode and the record that is asked for is seen, but when the reader is called into the DataTable using the .Load() function the DataReader shows a thrown exception of System.InvalidOperationException in the Depth and FieldCount properties when viewed in Debug mode

Code:
<br />
<small>msUserName = Request.QueryString.Get("username");<br />
            <br />
LabelUserName.Text = msUserName;<br />
UserName.Value = msUserName;<br />
moMembershipUser = Membership.GetUser(msUserName);<br />
<br />
msEmailAddress = moMembershipUser.Email;<br />
            <br />
moSqlConnection = new SqlConnection();<br />
moSqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AppSqlServer"].ConnectionString;<br />
<br />
moSqlCommand = new SqlCommand();<br />
moSqlCommand.CommandText = "SELECT * From tblUserInfo WHERE UserID = @UserID ";<br />
moSqlCommand.CommandType = CommandType.Text;<br />
moSqlCommand.Connection = moSqlConnection;<br />
            <br />
// UserID Parameter<br />
moSqlParameterUser = new SqlParameter();<br />
moSqlParameterUser.ParameterName = "@UserID";<br />
moSqlParameterUser.SqlDbType = SqlDbType.UniqueIdentifier;<br />
moSqlParameterUser.Direction = ParameterDirection.Input;<br />
moSqlParameterUser.Value = new Guid(moMembershipUser.ProviderUserKey.ToString());<br />
            <br />
moSqlCommand.Parameters.Add(moSqlParameterUser);<br />
moSqlCommand.Connection.Open();<br />
<br />
moSqlDataReader = moSqlCommand.ExecuteReader(CommandBehavior.CloseConnection);<br />
<br />
moDataTable = new DataTable();<br />
moDataTable.Load(moSqlDataReader);<br />
<br />
if (moDataTable.Rows.Count == 0){<br />
      msFirstName = "";<br />
      msLastName = "";<br />
}else{<br />
      moDataTable.PrimaryKey = new DataColumn[] { moDataTable.Columns["UserID"] };<br />
      msFirstName = moDataTable.Rows.Find("FirstName");<br />
      msLastName = moDataTable.Rows.Find("LastName");<br />
}<br />
<br />
FirstName.Text = msFirstName;<br />
LastName.Text = msLastName;<br />
EmailAddress.Text = msEmailAddress;<br />
            <br />
moDataTable.Dispose();<br />
moSqlCommand.Dispose();<br />
moSqlConnection.Dispose();</small>


I dont understand why the application is returning this, I have checked the internet and several books but have found no reason for this error. I would appreciate if anyone could help fix this.

Thanks

modified on Monday, April 14, 2008 9:44 AM

GeneralRe: DataReader throws exception Pin
Herman<T>.Instance14-Apr-08 4:04
Herman<T>.Instance14-Apr-08 4:04 
GeneralRe: DataReader throws exception Pin
jamie21cor14-Apr-08 4:20
jamie21cor14-Apr-08 4:20 
GeneralRe: DataReader throws exception Pin
Herman<T>.Instance14-Apr-08 4:32
Herman<T>.Instance14-Apr-08 4:32 
GeneralRe: DataReader throws exception Pin
eyeseetee14-Apr-08 4:33
eyeseetee14-Apr-08 4:33 
GeneralRe: DataReader throws exception Pin
Soumini Ramakrishnan14-Apr-08 19:35
Soumini Ramakrishnan14-Apr-08 19:35 
Generalcomplete article about Membership and Role Management for ms sql server Pin
Farhad Eft14-Apr-08 3:31
Farhad Eft14-Apr-08 3:31 
GeneralRe: complete article about Membership and Role Management for ms sql server Pin
eyeseetee14-Apr-08 4:05
eyeseetee14-Apr-08 4:05 
QuestionProblem in Logout in asp.net using C# Pin
vinay_K14-Apr-08 3:22
vinay_K14-Apr-08 3:22 
GeneralRe: Problem in Logout in asp.net using C# Pin
eyeseetee14-Apr-08 3:25
eyeseetee14-Apr-08 3:25 
GeneralRe: Problem in Logout in asp.net using C# Pin
Christian Graus14-Apr-08 4:07
protectorChristian Graus14-Apr-08 4:07 
GeneralRe: Problem in Logout in asp.net using C# Pin
Abisodun14-Apr-08 6:29
Abisodun14-Apr-08 6:29 
GeneralRegarding Logout problem in ASP.net 2.0 using C# Pin
vinay_K14-Apr-08 3:21
vinay_K14-Apr-08 3:21 
GeneralRe: Regarding Logout problem in ASP.net 2.0 using C# Pin
Christian Graus14-Apr-08 4:06
protectorChristian Graus14-Apr-08 4:06 
QuestionHow to use message box in asp.net Pin
Deepak Nigam14-Apr-08 1:16
Deepak Nigam14-Apr-08 1:16 
AnswerRe: How to use message box in asp.net Pin
Christian Graus14-Apr-08 1:22
protectorChristian Graus14-Apr-08 1:22 
GeneralRe: How to use message box in asp.net Pin
Deepak Nigam14-Apr-08 1:59
Deepak Nigam14-Apr-08 1:59 
GeneralRe: How to use message box in asp.net Pin
Christian Graus14-Apr-08 3:03
protectorChristian Graus14-Apr-08 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.