Reputation: 111
what is the best way to call a stored procedure and still have a very low response time in asp.net ? i have tried filling a dataset from an adapter:
SqlConnection conn = new SqlConnection(dbm.ConnectionString);
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.CommandText = "";
sqlcom.Parameters.Add(new SqlParameter("@SOME_ID", Session[IWConstants.SessionAccountID]));
sqlcom.Parameters.Add(new SqlParameter("@END_DATE", ""));
sqlcom.Parameters.Add(new SqlParameter("@FILTER_OPTION", ""));
sqlcom.Parameters.Add(new SqlParameter("@START_DATE", ""));
SqlDataAdapter sqlDA = new SqlDataAdapter(sqlcom);
DataSet ds = new DataSet();
sqlDA.Fill(ds);
csvDataTable = ds.Tables[0];
and this block is giving me 11,000 plus milli seconds in response is there a better way of doing it ??
Upvotes: 1
Views: 133
Reputation: 8214
What you have written is definitely one of the most efficient ways. I assume that you acrually set the CommandText
to the name of your stored procedure.
Your response time probably has to do with either network topology or available sql server resources. (Assuming your sp excutes on very short time when tested directly on the sql server.)
Check out the second table on this page http://ormeter.net/ to see how much an ORM adds to execution time if that is what you are considering that as an option.
If you want to micro-optimize what happens in client code you could use a datareader instead of filling a dataset. That has slightly lower overhead, but in comparison to accessing the database it's usually negligable.
Upvotes: 1