FOR WEB
using System.Collections;
ArrayList ArrSql1 = new ArrayList();
ArrSql1.Add("COMMAND");
private bool DBWriter(ArrayList SQL)
{
try
{
SqlCommand DBCommand = new SqlCommand();
SqlTransaction DBTransaction;
SqlConnection DBConnection = new SqlConnection();
DBConnection.ConnectionString = ConfigurationManager.ConnectionStrings["INFOBCKConnectionString"].ConnectionString.Trim();
DBConnection.Open();
DBCommand = DBConnection.CreateCommand();
DBTransaction = DBConnection.BeginTransaction("SQLTransaction");
DBCommand.Connection = DBConnection;
DBCommand.Transaction = DBTransaction;
try
{
for (Int32 i = 0; i < SQL.Count; i++)
{
DBCommand.CommandText = SQL[i].ToString();
DBCommand.ExecuteNonQuery();
}
DBTransaction.Commit();
return true;
}
catch (Exception ex)
{
DBTransaction.Rollback();
ex.ToString();
return false;
}
}
catch (Exception ex)
{
ex.ToString();
return false;
}
}
沒有留言:
張貼留言