chandu123:
- hi i want to display data into textbox from database but when im executing this code im getting password only the other textbox is empty im not getting the username?? <BR>im getting <FONT face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">System.IndexOutOfRangeException: user this error at textbox1 i dnt knw any help?<BR> </FONT><BR><BR> if (!IsPostBack)
- {
- if (Session["user"] != "")
- {
-
- con.Open();
- SqlCommand cmd = new SqlCommand("select * from regform where username='" + Session["user"].ToString() + "'", con);
- SqlDataReader dr = cmd.ExecuteReader();
- dr.Read();
- if (dr.HasRows)
- {
- TextBox1.Text = dr["user"].ToString();
- TextBox2.Text = dr["password"].ToString();
-
- }
- con.Close();
hi i want to display data into textbox from database but when im executing this code im getting password only the other textbox is empty im not getting the username??
im getting System.IndexOutOfRangeException: user this error at textbox1 i dnt knw any help?
if (!IsPostBack)
{
if (Session["user"] != "")
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from regform where username='" + Session["user"].ToString() + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
TextBox1.Text = dr["user"].ToString();
TextBox2.Text = dr["password"].ToString();
}
con.Close();
chandu123 thanks for your post.
things you have to check it
1. YOur table regform having the column "user"
2. Execute the same query select * from regform where username='" + Session["user"].ToString() + "'", from the backend and see whether all columns having data.
3. Check your specified column ( TextBox1.Text = dr["user"].ToString(); ) is correct or not.
These scenario may problem on your case.
Any doubts please feel free to ask me.
If this post is answer of your question then don't forgot to Click Mark As Answer.
Thanks & Regards,
J.Jeyaseelan