Click here to Skip to main content
15,889,507 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hai i have a problem with ado.net

I read 30,000 values from database but i use each value in application ..
i compare each value with some range how can i read single values one after another..

pls give me replay urgent..

[edit]Tags.[/edit]
Posted
Updated 6-Jun-10 21:37pm
v2
Comments
Sandeep Mewara 7-Jun-10 3:34am    
First of all, your question is not quite clear. Secondly, it might be urgent to you but people here look based on their free time so you need to keep patience.
Ahmed Mostafa Al-Sayed 7-Jun-10 4:26am    
Reason for my vote of 2
Moderate

Hello Kiran,

As long as you are using the data in a read-only way, the optimum solution is to use any class that implements the DataReader interface, e.g. SqlDataReader, here is an example from MSDN:
C#
private static void ReadOrderData(string connectionString)
{
    int min = 1, max = 10;
    string queryString = "SELECT PriceValue FROM dbo.Prices;";

    using( SqlConnection connection = new SqlConnection(connectionString) )
    {
        SqlCommand command = new SqlCommand(queryString, connection);
        connection.Open();

        SqlDataReader reader = command.ExecuteReader();

        // Call Read before accessing data.
        while( reader.Read() )
        {
            if( reader["PriceValue"] < min )
                Console.WriteLine( "Value is too low." );
            if( reader["PriceValue"] > max )
                Console.WriteLine( "Value is too high." );
        }

        // Call Close when done reading.
        reader.Close();
    }
}


Hope this helps
 
Share this answer
 
All depends what object you are using to retrieve your information from the database.

Are you using a DataReader? If so, something like

C#
using (IDataReader reader = cmd.ExecuteReader())
{
    while (reader.Read())
    {
        int myValue = reader.GetInt32(0);
        if (myValue == someTest)
        {
            // DoSomething
        }
    }
}


Or from a Dataset...?

C#
DataSet ds = adapter.Fill(myDataSet);
System.Data.DataTable dt = ds.Tables[0];

foreach(DataRow dr in dt.Rows)
{
    int myValue = Convert.ToInt32(dr[0]);
    if (myValue == someTest)
    {
        // DoSomething
    }
}
 
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