/// <summary> /// Retrieve a parameter array from the cache /// </summary> /// <param name="connectionString">A valid connection string for a SqlConnection</param> /// <param name="commandText">The stored procedure name or T-SQL command</param> /// <returns>An array of SqlParamters</returns> public static System.Data.SqlClient.SqlParameter[] GetCachedParameterSet(string connectionString, string commandText) { System.Data.SqlClient.SqlParameter[] sqlParameterArr1; if ((connectionString == null) || (connectionString.Length == 0)) { throw new System.ArgumentNullException("connectionString"); } if ((commandText == null) || (commandText.Length == 0)) { throw new System.ArgumentNullException("commandText"); } string s = connectionString + ":" + commandText; sqlParameterArr1 = (System.Data.SqlClient.SqlParameter[])SqlHelperParameterCache.paramCache[s]; if (sqlParameterArr1 == null) { return(null); } else { return(SqlHelperParameterCache.CloneParameters(sqlParameterArr1)); } }
/// <summary> /// Retrieves the set of SqlParameters appropriate for the stored procedure /// </summary> /// <remarks> /// This method will query the database for this information, and then store it in a cache for future requests. /// </remarks> /// <param name="connection">A valid SqlConnection object</param> /// <param name="spName">The name of the stored procedure</param> /// <param name="includeReturnValueParameter">A bool value indicating whether the return value parameter should be included in the results</param> /// <returns>An array of SqlParameters</returns> public static System.Data.SqlClient.SqlParameter[] GetSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter) { SqlConnection sqlConnection = null; System.Data.SqlClient.SqlParameter[] sqlParameterArr; if ((connectionString == null) || (connectionString.Length == 0)) { throw new System.ArgumentNullException("connectionString"); } try { sqlConnection = new SqlConnection(connectionString); sqlParameterArr = SqlHelperParameterCache.GetSpParameterSetInternal(sqlConnection, spName, includeReturnValueParameter); } finally { if (sqlConnection != null) { sqlConnection.Dispose(); } } return(sqlParameterArr); }
/// <summary> /// Retrieves the set of SqlParameters appropriate for the stored procedure /// </summary> /// <remarks> /// This method will query the database for this information, and then store it in a cache for future requests. /// </remarks> /// <param name="connectionString">A valid connection string for a SqlConnection</param> /// <param name="spName">The name of the stored procedure</param> /// <param name="includeReturnValueParameter">A bool value indicating whether the return value parameter should be included in the results</param> /// <returns>An array of SqlParameters</returns> public static System.Data.SqlClient.SqlParameter[] GetSpParameterSet(SqlConnection connection, string spName, bool includeReturnValueParameter) { SqlConnection sqlConnection = null; System.Data.SqlClient.SqlParameter[] sqlParameterArr; if (connection == null) { throw new System.ArgumentNullException("connection"); } try { sqlConnection = (SqlConnection)((ICloneable)connection).Clone(); sqlParameterArr = SqlHelperParameterCache.GetSpParameterSetInternal(sqlConnection, spName, includeReturnValueParameter); } finally { if (sqlConnection != null) { sqlConnection.Dispose(); } } return(sqlParameterArr); }
/// <summary> /// Retrieves the set of SqlParameters appropriate for the stored procedure /// </summary> /// <remarks> /// This method will query the database for this information, and then store it in a cache for future requests. /// </remarks> /// <param name="connection">A valid SqlConnection object</param> /// <param name="spName">The name of the stored procedure</param> /// <returns>An array of SqlParameters</returns> public static System.Data.SqlClient.SqlParameter[] GetSpParameterSet(string connectionString, string spName) { return(SqlHelperParameterCache.GetSpParameterSet(connectionString, spName, false)); }