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.CommandTy pe = CommandType.Sto redProcedure;
m_con.Open();
SqlDataReader m_dr ;
m_dr = m_CMD.ExecuteRe ader();
while (m_dr.Read())
{
lb_ID.Items.Add (m_dr.GetValue( 0).ToString());
lb_Name.Items.A dd(m_dr.GetValu e(1).ToString() );
}
m_dr.Close();
m_con.Close();
/* Code ends */
I want to optimize the code, Any body having Idea ?
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.CommandTy pe = CommandType.Sto redProcedure;
m_con.Open();
SqlDataReader m_dr ;
m_dr = m_CMD.ExecuteRe ader();
while (m_dr.Read())
{
lb_ID.Items.Add (m_dr.GetValue( 0).ToString());
lb_Name.Items.A dd(m_dr.GetValu e(1).ToString() );
}
m_dr.Close();
m_con.Close();
/* Code ends */
I want to optimize the code, Any body having Idea ?
Comment