Tuesday, March 20, 2012

rs.getrows equivalent

Hi

Is there and equivalent of rs.getrows in asp.net? I want to fill an array quickly from a datareader?

ta
LbobIf you're using a DataReader you can add the items to an ArrayList so you don't need to know the number of records. This can be useful in some cases. Furthermore, if you're in the presentation code itself you can just set the DataReader as the DataSource of a control and do a DataBind on the control to display the contents on the control. There is a RecordsAffected property as well which may be helpful if you still want to determine the number of affected records by the query.|||I think it became depreciated when the DataTable object came out with ado.net


// first loop is the first dimension array similarity
for (int i=0;i<DataTable.Rows.Count;i++) {
// second loop is the second dimension array similarity
for (int j=0;j<DataTable.Columns.Count;j++) {
// output the contents to the output window.
System.Diagnostics.Debug.WriteLine(DataTable.Rows[i][j].ToString());
}
}

No comments:

Post a Comment