i hae a ole data reader which contains records extracted from Query.how can i check for end of file in data reader.and i want to know the number of records present in data reader
thanks in advance
i hae a ole data reader which contains records extracted from Query.how can i check for end of file in data reader.and i want to know the number of records present in data reader
thanks in advance
1.DataReader provides only way to read data in forward only and read only mode. So you have to read each record one by one by using Read() method of data reader and you have to predict that there is no more record once Read method returns false and now current record would be the last record.
2.There is no property/method to know no.of rows in a datareader. You need to run a for loop to read data from datareader and increment an index variable unless it reaches end of datareader(when Read method of DataReader returns false).
i hae a ole data reader which contains records extracted from Query.how can i check for end of file in data reader.and i want to know the number of records present in data reader
thanks in advance
I like to use an OleDbDataAdapte r instead. use it like this:
[CODE=cpp]
//this is c# code, but the VB.NET is similar.
string sql = "select * from whateverTable";
string connStr = "connection string goes here";
OleDbConnection conn = new OleDbConnection (connStr);
OleDbDataAdapte r adapt = new OleDbDataAdapte r(sql,conn);
DataSet ds = new DataSet();
adapt.Fill(ds," table_name");
//now you have access to the whole query's recordset in a DataTable!
//here's how you get to it.
DataTable table = ds.Tables["table_name "];
[/CODE]
Now you can manipulate your whole recordset inside that DataTable. Also, you can check the total # of records like this:
I like to use an OleDbDataAdapte r instead. use it like this:
[CODE=cpp]
//this is c# code, but the VB.NET is similar.
string sql = "select * from whateverTable";
string connStr = "connection string goes here";
OleDbConnection conn = new OleDbConnection (connStr);
OleDbDataAdapte r adapt = new OleDbDataAdapte r(sql,conn);
DataSet ds = new DataSet();
adapt.Fill(ds," table_name");
//now you have access to the whole query's recordset in a DataTable!
//here's how you get to it.
DataTable table = ds.Tables["table_name "];
[/CODE]
Now you can manipulate your whole recordset inside that DataTable. Also, you can check the total # of records like this:
[CODE=cpp]
table.Rows.Coun t;
[/CODE]
Hello,
DataTable could be valuable solution for your problem.
Comment