Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,

In mobile application for retriving data from database i am using Datareader concept for fast accessing the information
but while reading the data it takes minimum 5 minutes it has only 10 records.
How to increase the performance of my application please suggest me this argent requirement

This is my code

C#
SqlCeConnection conn = null;
SqlCeCommand cmd = null;
SqlCeDataReader rdr = null;

try
{    
    conn = new SqlCeConnection("Data Source = AdventureWorks.sdf");
    conn.Open();

    cmd = new SqlCeCommand("SELECT * FROM DimEmployee", conn);

    rdr = cmd.ExecuteReader();
   
    while (rdr.Read())
    {
        int employeeID = rdr.GetInt32(0);   // or: rdr["EmployeeKey"];
        string lastName = rdr.GetString(5); // or: rdr["FirstName"];
    }
   
    rdr.Close();
    cmd.Dispose();
}
finally
{   
    conn.Close();
}


Regards
Ch.Sreenu
Posted
Updated 17-Dec-14 18:23pm
v2
Comments
BillWoodruff 18-Dec-14 0:19am    
It appears to me you are over-writing the variables with each execution of the 'while loop which means only the last read's values are going to be in those variables when you exit the loop.

Is that what you really want to do ?
PIEBALDconsult 18-Dec-14 0:26am    
The code could be better, but I don't see anything that would cause such poor performance.
Agent__007 18-Dec-14 1:49am    
OT: BTW did you notice "(no name)" against your profile in "Edited" section of this question? Kind of weird..
PIEBALDconsult 18-Dec-14 10:35am    
That happens, usually it updates after a while.
Praveen Kumar Upadhyay 18-Dec-14 1:18am    
Just to check where is the issue, Use DataAdapter and store data into DataSet. and see how much time it is taking to execute the query and to fill the dataset. I think there are some latency from your application to the Sql server. If your table has less rows then using DataSet will be much preferable.

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