Code
public bool ExecuteCommand(ArrayList SqlList)
{
con = new SqlConnection(str_constr);
con.Open();
SqlCommand _command;
bool iserror = false;
string strerror = "";
SqlTransaction SqlTran = con.BeginTransaction();
try
{
for (int i = 0; i < SqlList.Count; i++)
{
_command = new SqlCommand();
_command.Connection = con;
_command.CommandText = SqlList[i].ToString();
_command.Transaction = SqlTran;
_command.ExecuteNonQuery();
}
}
catch (Exception ex)
{
iserror = true;
strerror = ex.Message;
}
finally
{
if (iserror)
{
SqlTran.Rollback();
throw new Exception(strerror);
}
else
{
SqlTran.Commit();
}
con.Close();
}
if (iserror)
{
return false;
}
else
{
return true;
}
}
posted @
2008-08-09 08:59
陈旭85
阅读(
240)
评论()
编辑
收藏
举报