#region 批量处理Sql
/// <summary>
/// 批量处理Sql
/// </summary>
/// <param name="Array_Sql"></param>
/// <returns></returns>
public static bool FileInsertToData(string[] Array_Sql)
{
bool Result= true;
SqlConnection sqlConn = new SqlConnection(strConn);
SqlCommand Comm = sqlConn.CreateCommand();
SqlTransaction myTrans;
myTrans = sqlConn.BeginTransaction();
Comm.Connection = sqlConn;
Comm.Transaction = myTrans;
Comm.CommandType = CommandType.Text;
sqlConn.Open();
try
{
for (int i = 0; i < Array_Sql.Length; i++)
{
Comm.CommandText = Array_Sql[i].ToString();
Comm.ExecuteNonQuery();
}
myTrans.Commit();//事务提交
Result = true;
}
catch (Exception ex)
{
myTrans.Rollback();//事务回滚
Result = false;
}
finally
{
sqlConn.Close();
Comm.Dispose();
}
return Result;
}
#endregion