/// <summary>
/// execute SQL script,Keep SqlTransaction 。
/// </summary>
/// <param>save sql command and sql parameter</param>
public void ExecuteSqlTran(Dictionary<string ,SqlParameter []> objSqlList)
{
conn.Open();
using (SqlTransaction trans = conn.BeginTransaction())
{
try
{
SqlCommand sqlcmd = new SqlCommand();
//circulation
foreach (KeyValuePair<string, SqlParameter[]> kvp in objSqlList)
{
//the key value is by|Division ,Serial number|sql script
string[] tmp = kvp.Key.ToString().Split(new char[] { '|' });
string cmdText = tmp[1];
//get SqlParameter value
SqlParameter[] sqlParms = kvp.Value;
if (sqlParms!=null)
sqlcmd = SQLHelper.CreateCommand(cmdText, sqlParms, this.conn);
sqlcmd.Transaction = trans;
int val = sqlcmd.ExecuteNonQuery();
//clear SqlParameter
sqlcmd.Parameters.Clear();
}
trans.Commit();
}
catch
{
trans.Rollback();
throw;
}
finally
{
this.conn.Close();
}
}
}
#endregion
#endregion
#region other