Click here to Skip to main content
15,900,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using query like

select * from mew_file where process_id=6


I am getting 5 Rows with five cols

now i want to compare whole 3rd column with one valu lijr

if(reader["stage"]=100)
{
}

hear stage is the 3 rd column in my sql query I how can I compare.
Posted
Updated 22-Dec-11 0:12am
v2

Use WHEN - CASE in query, if you have any doubt then don't hesitate.
 
Share this answer
 
C#
ArrayList myarr = new ArrayList();
       for(int i=0;i<ds.tables[0].rows.count;i++)>
       {

        myarr.Add(ds.Tables[0].Rows[i]["Third_ClumnName"].ToString());

       }


Now you have all values in "myarr" array.

Then, you can assign a string what you want to compare.

After that compare that string with each element of Array.
 
Share this answer
 
use dataset to fetch data from database, because it is connection less.
and then you can compare in this way :
C#
Dataset ds=new Dataset();
ds= // get data into ds;
for ( int i=0; i<ds.tables[0].rows.count;>{
  if( Convert.ToInt32(ds.Tables[0].Rows[i][2])==100)  // 2 is index of column
   {
     // code here that u want to do;
   }
  else
   {
    // else condition
   }
}


Hope this will surely help you.
Don't forget to mark as answer if it helps. :)
 
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