Click here to Skip to main content
15,904,638 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

In my project i m using autocomplete textbox. i m binding the Phone no from database in autocomplete textbox. I have more than 500 records in my table (phone no table). it loading very slow in my method. how can i increase performance for autocomplete. if any one know solution for this plz just reply me...

thanks & regards
C#
OleDbCommand cmd1 = null; OleDbCommand cmd11 = null;
namesCollection1.Clear();
cmd1 = new OleDbCommand("select * from InvoiceDetails", Con);
OleDbDataReader dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
    if (!namesCollection1.Contains(dr1[4].ToString()))
    {
        namesCollection1.Add(dr1[4].ToString());
    }
}
cmd1.Dispose();
dr1.Dispose();


cmd11 = new OleDbCommand("select * from CustomerDetails", Con);
OleDbDataReader dr11 = cmd11.ExecuteReader();
while (dr11.Read())
{
    if (!namesCollection1.Contains(dr11[11].ToString()))
    {
        namesCollection1.Add(dr11[11].ToString());
    }
}
cmd11.Dispose();
dr11.Dispose();

PhoneNoText.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
PhoneNoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
PhoneNoText.AutoCompleteCustomSource = namesCollection1;



[edit]Added code block posted by OP as comment - Original Griff[/edit]
Posted
Updated 22-Nov-13 22:01pm
v2
Comments
OriginalGriff 23-Nov-13 3:45am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Perhaps if you show us the code you use to load the data it might help?
Use the "Improve question" widget to edit your question and provide better information.
OriginalGriff 23-Nov-13 4:02am    
You don't need to post code as a comment, or reply - add it to your question using the "Improve question" widget.
I have moved it into your question, and deleted the comment.
agent_kruger 23-Nov-13 5:38am    
is getting the data from db taking time or autocomplete function is taking time?

1 solution

Speeding things up is never a "do this" solution - it's an iterative process that needs a fair amount of "feel".

The first thing to do is to time exactly what is happening, so you get a feel for how fast or slow the various parts are, and how much difference each change you make actually does.

So: look at the Stopwatch class
C#
Stopwatch sw1 = new Stopwatch();
sw1.Start();
... do code to time
sw1.Stop();
Console.WriteLine("Stopwatch1: {0,06}", sw1.ElapsedMilliseconds);

This gives you a base to work from.
Run that half a dozen times so you have a small range of values to compare later.

Then, start by only returning the data from SQL that you actually need:
SQL
SELECT MyColumn FROM InvoiceDetails
Is a lot more efficient than
SQL
SELECT * FROM InvoiceDetails
Because it only returns the data you actually need. In one case you are returning at least ten columns that you don't want or use!

Time that again several times, and show me the results in both cases.
 
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