public bool ExecNonQuery(ArrayList stringUpdate)
{
if(!OpenConnection())
{
return false;
}
bool bSuccessed = true;
//使用的是本地事务,不能执行远程事务
SqlTransaction SqlTransactionInfo = null;
try
{
SqlTransactionInfo = m_SqlConnectionInfo.BeginTransaction(IsolationLevel.ReadCommitted);
SqlCommand SqlCommandInfo = new SqlCommand();
SqlCommandInfo.Connection = m_SqlConnectionInfo;
SqlCommandInfo.CommandType = CommandType.Text;
SqlCommandInfo.Transaction = SqlTransactionInfo;
for(int i = 0; i < stringUpdate.Count; i++)
{
SqlCommandInfo.CommandText = stringUpdate[i].ToString();
SqlCommandInfo.ExecuteNonQuery();
}
SqlTransactionInfo.Commit();
}
catch(Exception /*ex*/)
{
bSuccessed = false;
}
finally
{
SqlTransactionInfo.Rollback();
CloseConnection();
}
return bSuccessed;
}
{
if(!OpenConnection())
{
return false;
}
bool bSuccessed = true;
//使用的是本地事务,不能执行远程事务
SqlTransaction SqlTransactionInfo = null;
try
{
SqlTransactionInfo = m_SqlConnectionInfo.BeginTransaction(IsolationLevel.ReadCommitted);
SqlCommand SqlCommandInfo = new SqlCommand();
SqlCommandInfo.Connection = m_SqlConnectionInfo;
SqlCommandInfo.CommandType = CommandType.Text;
SqlCommandInfo.Transaction = SqlTransactionInfo;
for(int i = 0; i < stringUpdate.Count; i++)
{
SqlCommandInfo.CommandText = stringUpdate[i].ToString();
SqlCommandInfo.ExecuteNonQuery();
}
SqlTransactionInfo.Commit();
}
catch(Exception /*ex*/)
{
bSuccessed = false;
}
finally
{
SqlTransactionInfo.Rollback();
CloseConnection();
}
return bSuccessed;
}