Stored Procedure Helper Functions

public SqlDataReader executeSPHelper(string cmdStr,ArrayList cmdParams)
{

SqlDataReader rd=null;
SqlCommand sqlCmd=null;

try
{

sqlCmd = new SqlCommand(cmdStr,yourConnection);
sqlCmd.CommandType = CommandType.StoredProcedure;

foreach (SqlParameter sqlParam in cmdParams)
{
sqlCmd.Parameters.Add(sqlParam);
}

rd = sqlCmd.ExecuteReader();

return rd;
}

catch(Exception e)
{
}
finally
{
sqlCmd=null;
}
}

public System.Data.SqlClient.SqlCommand executeSPCommandHelper(string cmdStr,ArrayList cmdParams)
{

SqlCommand sqlCmd=null;

try
{

sqlCmd = new SqlCommand(cmdStr,yourConnection);
sqlCmd.CommandType = CommandType.StoredProcedure;

foreach (SqlParameter sqlParam in cmdParams)
{
sqlCmd.Parameters.Add(sqlParam);
}

//rd = sqlCmd.ExecuteReader();

return sqlCmd;
}

catch(Exception e)
{

}
finally
{
sqlCmd=null;
}
}

public System.Data.SqlClient.SqlCommand executeSPCommandHelper(string cmdStr)
{

SqlCommand sqlCmd=null;

try
{

sqlCmd = new SqlCommand(cmdStr,yourConnection);
sqlCmd.CommandType = CommandType.StoredProcedure;

return sqlCmd;
}

catch(Exception e)
{
}
finally
{
sqlCmd=null;
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *