retrieve data from Database based on SessionID and populating the textboxes.. [modified]
-
had posted this yesterday but since my ques wasnt proper didnt get many answers..well i want populate my textboxes based on the sessionid with data from database..through that id am populating the textboxes which are the fields in the table..am using datareader's reader method but havin problem..do help..below is the code..
if (Session["User"] == null) Response.Redirect("Default4.aspx");
filltrans(System.Convert.ToString(Session["User"]));
private void filltrans(string User)
{
try
{
SqlDataReader reader;
string ConnectionString="...";
SqlConnection con = new SqlConnection(ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("View", con);cmd.CommandType = CommandType.StoredProcedure; SqlParameter\[\] userdetail = new SqlParameter\[1\]; userdetail\[0\] = new SqlParameter("@User\_ID", SqlDbType.VarChar,50); userdetail\[0\].Value = User.ToString(); reader = cmd.ExecuteReader(); while(reader.Read()) { txtuser.Text = System.Convert.ToString(reader\["user"\]); txtusername.Text = System.Convert.ToString(reader\["user\_new"\]); txtmobileno.Text = reader\["MobileNo"\].ToString(); } reader.Close(); } catch (Exception ex) { } }
when i compile and check with breakpoints i found that after the executeReader method its not goin into while loop at all.. thanks..
scarface
modified on Tuesday, March 10, 2009 1:10 AM
-
had posted this yesterday but since my ques wasnt proper didnt get many answers..well i want populate my textboxes based on the sessionid with data from database..through that id am populating the textboxes which are the fields in the table..am using datareader's reader method but havin problem..do help..below is the code..
if (Session["User"] == null) Response.Redirect("Default4.aspx");
filltrans(System.Convert.ToString(Session["User"]));
private void filltrans(string User)
{
try
{
SqlDataReader reader;
string ConnectionString="...";
SqlConnection con = new SqlConnection(ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("View", con);cmd.CommandType = CommandType.StoredProcedure; SqlParameter\[\] userdetail = new SqlParameter\[1\]; userdetail\[0\] = new SqlParameter("@User\_ID", SqlDbType.VarChar,50); userdetail\[0\].Value = User.ToString(); reader = cmd.ExecuteReader(); while(reader.Read()) { txtuser.Text = System.Convert.ToString(reader\["user"\]); txtusername.Text = System.Convert.ToString(reader\["user\_new"\]); txtmobileno.Text = reader\["MobileNo"\].ToString(); } reader.Close(); } catch (Exception ex) { } }
when i compile and check with breakpoints i found that after the executeReader method its not goin into while loop at all.. thanks..
scarface
modified on Tuesday, March 10, 2009 1:10 AM
Check your Stored Procedure. It might be possible your stored procedure is not returning any row for that User.
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.
-
Check your Stored Procedure. It might be possible your stored procedure is not returning any row for that User.
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.