开发者

ASP.net equivalent of ASP's rs.getRows()

开发者 https://www.devze.com 2023-01-12 13:11 出处:网络
In classic ASP, you can dump a recordset into an array using getRows().This is a lot faster way of looping results, and frees up the recordset earlier.

In classic ASP, you can dump a recordset into an array using getRows(). This is a lot faster way of looping results, and frees up the recordset earlier.

Is the开发者_如何学Gore an equivalent in ASP.net (c#?). I've had a look on google and all I can find is a bunch of ugly while loops that dump the rows in an array list, is there a nicer way of doing this?

Thanks!


In ADO.Net, the dataset is a disconnected, in-memory representation of data, so you don't need this step.


As RedFilter said, ADO.Net (so Asp.Net) can work disconnected scenario. I think DataAdapter and Datatable is best match for you. For example

SqlConnection conn = new SqlConnection("CONNECTION_STRING");
conn.Open;

SqlCommand comm = conn.CreateCommand();
comm.CommandText = "SELECT * from Table";

SqlDataAdapter da = new SqlDataAdapter(comm);
DataTable table = new DataTable();

da.Fill(table); // Here is equivalent with getRows()

So you fetched all your data to table variable. You can bind this object to a control or you can manipulate the data manually.

0

精彩评论

暂无评论...
验证码 换一张
取 消