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

I have website in c#.

i have Dropdownlist SelectedIndexChanged event, to get values.
DataTable dt = new DataTable();
        SqlParameter[] p = new SqlParameter[1];
        p[0] = new SqlParameter("@RefID", Convert.ToInt32(i));
        dt = dl.GetDataWithParameters("Sp_WT_GetRef", p);//method which fill dt

        b.Text = dt.Rows[0]["unit"].ToString();
        c.Text = dt.Rows[0]["PriceInUSD"].ToString();
        a.Text = dt.Rows[0]["description"].ToString();

GetDataWithParameters Method
public DataTable GetDataWithParameters(string StoredProcedureName, SqlParameter[] param)
            SqlConnection conn = null;
                DataTable tb = null;
                conn = conn = GetConnectionString();
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, StoredProcedureName, param);
                tb = ds.Tables[0];
                return tb;
            catch (Exception ee)
                return null;


Stored Procedure
alter Proc Sp_WT_GetRef
(@RefID int)


  FROM [tbl_WT_References]
  Where RecID = @RefID

n i have published on client server(ftp).

its taking minimum 6 seconds to gets the values...

can any one plz help me, how can i get these values fast....

Updated 12-May-15 23:56pm
Herman<T>.Instance 13-May-15 4:21am    
How long does the call to Sp_WT_GetRef?
abdul subhan mohammed 13-May-15 4:27am    
Herman<T>.Instance 13-May-15 4:28am    
the problem might be the query, or the indexstrategy in the database, not the c# sourcecode.
I think the below line takes time...

dt = dl.GetDataWithParameters("Sp_WT_GetRef", p);//method which fill dt
Abhipal Singh 13-May-15 13:40pm    
How much time does the SP execution takes on SQL Server Management Studio? Run the SP manually and check the results.

How much data is there in the table?

If SP is taking time to get the values, it will slow down the entire thing.
If that is the case, try to create index on RefID column and see if your SP performs better.

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