_DotNetStuff and more...

Wednesday, May 04, 2005

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;
}
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home