Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,
I have one problem... I read 20000 rows at a time, but I use only one row and after processing, I use another row.
How can I do this?
Please reply.

See here:

con = new SqlConnection(nrdet);
       SqlDataAdapter da = new SqlDataAdapter("select E1,SM1,R1,E2,SM2,R2,E3,SM3,R3,E4,SM4,R4,E5,SM5,R5,E6,SM6,R6,E7,SM7,R7,E8,SM8,R8,E9,SM9,R9,E10,SM10,R10 From TOTAL_NR WHERE SCHEME='" + DropDownList1.SelectedItem.Text + "' AND YR='" + DropDownList2.SelectedItem.Text + "' AND RESULT=3", con);
       DataSet ds = new DataSet();
       da.Fill(ds);

Actually, here there are 2000 rows, but I compare rows one after another.

I use E1,SM1,R1 values first I compare those results after E2,SM2,R2.....
Posted
Updated 8-Jun-10 1:43am
v4

You can loop through the result set?
I may not have understood your question properly - maybe you need to post some code here.
 
Share this answer
 
Get a reference to the DataTable object and loop through the rows collection

DataSet ds = new DataSet();
da.Fill(ds);

DataTable dt = ds.Tables[0];

foreach(DataRow dr in dt.Rows)
{
    // Now use the dararow object to access your column fields
    if (Convert.ToInt32(dr["YourIntegerFieldName"]) == WhateverTest)
    {
        // Do something?
    }
}
 
Share this answer
 
hmm when you use the dataset you take all the records at once and keep them in the memory , while keeping them in memory you compare the values in the row,

but i would like to suggest you to use the SqlDataReader which takes only one record at a time , it will be good in performance wise , but u need to keep the db connection while process completes , if you want to use a disconnected data accessing, or editing data in the record, dataset is good .
but in this case using dataset means you keep 20000 records in memory.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900