Skip to main content


Showing posts from November, 2006

Cache Stored Procedure SqlParameter Objects

Cache Stored Procedure SqlParameter ObjectsApplies toADO.NET 1.1 What to DoOften, applications must run SQL commands multiple times, cache the Stored Procedure SqlParameter so that they can be reused later. WhyCaching the SqlParameter object avoids recreating the them each time the Stored Procedure needs to be called. Thus improving the performance of the application. WhenThis guideline should be followed whenever you have code repetitively calling stored procedure. HowA good approach is to cache parameter arrays in a Hashtable object. Each parameter array contains the parameters that are required by a particular stored procedure that is used by a particular connection. The following code fragment shows this approach.public static void CacheParameterSet(string connectionString,
string commandText,
params SqlParameter[] commandParameters)
if( connectionString == null || connectionString.Length == 0 )