Monday, March 19, 2012

DataReader access

Hi,

I am facing a problem to access datareader... actually i want to get data on lables from datareader. actually i am having one table having only one column and i hav accessed all data into datareader but the problem is that i just want to get data row by row...

For example there are four labels Label1, Label2, Label3, Label4

and want to print the data from datareader on to thease labels...

plz do reply... i am in trouble

//Create the DataReader by calling ExecuteReader()SqlDataReader myReader = myCommand.ExecuteReader();//Iterate through the DataReader in a while loopwhile (myReader.Read()){ // each row in DataReader
 Name = myReader.GetString(0);or
 Name = myReader["Name"].ToString();}//Close DataReadermyReader.Close();

HTH