datareader in asp.net using c#
-
Hi All, Can anybody help me?.... I am using a datareader to read from the database, i have the select query for this & reading the contents of the table ok... I am getting the correct output using a datareader for the datagrid ....as.... DGShow.DataSource=dread; DGShow.DataBind(); ...but i want to put the same contains in the textbox also....but whenever i read the contains i am getting this error message.... Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present. the code is...... while(dread.Read()) { txtEmpID.Text=dread.GetString(0); txtEmpName.Text =dread.GetString(1); txtcity.Text=dread.GetString(2); txtphone.Text=dread.GetInt32(3); } as i am not sure that i m on right track please help me.. thanks
-
Hi All, Can anybody help me?.... I am using a datareader to read from the database, i have the select query for this & reading the contents of the table ok... I am getting the correct output using a datareader for the datagrid ....as.... DGShow.DataSource=dread; DGShow.DataBind(); ...but i want to put the same contains in the textbox also....but whenever i read the contains i am getting this error message.... Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present. the code is...... while(dread.Read()) { txtEmpID.Text=dread.GetString(0); txtEmpName.Text =dread.GetString(1); txtcity.Text=dread.GetString(2); txtphone.Text=dread.GetInt32(3); } as i am not sure that i m on right track please help me.. thanks
-
Hi All, Can anybody help me?.... I am using a datareader to read from the database, i have the select query for this & reading the contents of the table ok... I am getting the correct output using a datareader for the datagrid ....as.... DGShow.DataSource=dread; DGShow.DataBind(); ...but i want to put the same contains in the textbox also....but whenever i read the contains i am getting this error message.... Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present. the code is...... while(dread.Read()) { txtEmpID.Text=dread.GetString(0); txtEmpName.Text =dread.GetString(1); txtcity.Text=dread.GetString(2); txtphone.Text=dread.GetInt32(3); } as i am not sure that i m on right track please help me.. thanks
You can't use a datareader as your datasource if your binding more than one control to it. You would have to bind them to a datatable in a dataset... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome