473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VERY SLOW EXECUTION - VC# APPLICATION with MS SQL 2000

mathewphilipp
Dear all,
I have a VC# (winforms) application written in Visual studio 2003 with .Net framework 1.1, here I want to populate 6 listboxes with bulk amount of data ( Eg. combox A and B each with 20000 items , combobox C and D each with 4500 items , combox E and F each with 100 items). I am using a stored procedure here , Please see the following example ( other stored proceduers and code blocks are also same but having differnt names) it takes around 40 Minuts to load the form with populated controls....!!!!!

/* SP */
CREATE PROCEDURE sp_name AS
begin
select id,name from tableName order by name
end
GO

/* VC# code */
SqlCommand m_CMD = new SqlCommand("sp_name",m_con); // EXECUTING STORED PROCEDURE TO LOAD ITEMS

m_CMD.CommandType = CommandType.StoredProcedure;

m_con.Open();

SqlDataReader m_dr ;

m_dr = m_CMD.ExecuteReader();

while (m_dr.Read())

{

lb_ID.Items.Add(m_dr.GetValue(0).ToString());

lb_Name.Items.Add(m_dr.GetValue(1).ToString());

}

m_dr.Close();

m_con.Close();

/* Code ends */

I want to optimize the code, Any body having Idea ?
Sep 25 '07 #1
4 1398
Plater
7,872 Expert 4TB
Use a DataAdapter to fill a DataTable (or DataSet) and then use the DataSource property to populate your comboboxes.

Although 4500 is a bit excessive....who's gonna want to sift through that?
Sep 25 '07 #2
Use a DataAdapter to fill a DataTable (or DataSet) and then use the DataSource property to populate your comboboxes.

Although 4500 is a bit excessive....who's gonna want to sift through that?
According to me 4500 is lesser i have to load 20000 each in 2 list boxes, its loading in a kool manner, Only problem is time consuming around 25 minutes it takes. its a must to load all the items.. Data adaptor and datatable combination is already used it takes more time than that of reader
Sep 25 '07 #3
Plater
7,872 Expert 4TB
Well I'm not sure what to tell you except to try and find a way to split it up.
A good rule of thumb is no more then a couple dozen entries (say 50?) in a dropdrown.
That's a number out of hat, but you should be able to do a limiting thing.
We have a page that has a dropdown of a potential 18,000 different items. However we don't load the oldest 9,000 unless required too.
Sep 25 '07 #4
Hello,

I am solved the issue by binding the datatable directly to the control. Now I am not using any loop. Loop made it slow.

Thanks

Mathew Philip
Oct 1 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: mamo74 | last post by:
Hello. I am administering a SQL Server (Enterprise Edition on Windows 2003) from some month and can't understand what is going on in the latest week (when the db grow a lot). The DB is around...
6
by: B B | last post by:
Okay, here is what's happening: I have a reasonably fast laptop (1.4 GHz Mobile M, so comparable to 2.5GHz P4) doing .net development. Running Windows XP pro, SP2 IIS is installed and running...
2
by: jim.clifford | last post by:
Hello. I have a slow response with a system that I am setting up. The OS is Win 2000 Server with SQL Server 2000. My first execution of the SQL procedure is slow (about 40 seconds), while the...
11
by: HC | last post by:
I posted this in one of the VB forums but I'm starting to think it might be more appropriate to have it here, since it really seems to be a SQL server (MSDE/Express 2005) problem: Hey, all, I...
3
by: pramodbura | last post by:
We have a quick query regarding SQL performance. We have SQL Server 2000 (32 Bit) and SQL Server 2005 (64 Bit) as two separate instances on a DB Server. We were analysing the execution times for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.