SqlDataReader

  • Thread starter Thread starter Ghost
  • Start date Start date
G

Ghost

Can I get record as DataRow object from SqlDataReader (if yes how)?
 
Try creatinga DataTable
Following code may help

//Create A DataTable
DataTable dTable = new DataTable();
//Get the totla number of fields in the reader
int colCounter = reader.FieldCount;
int recordRead = 0 ;
for (int i = 0 ; i < colCounter ; i++)
{
dTable.Columns.Add(reader.GetName(i),reader.GetFieldType(i));
}
dTable.BeginLoadData();
object[] values = new object[colCounter];
while (reader.Read())
{

reader.GetValues(values);
dTable.LoadDataRow(values,true);

}
dTable.EndLoadData();



Regards
Dinesh Kalawat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top