请参考下面的代码
private bool DbExecuteNonQueryForMsSQL(string[] SqlStr)
{
//
System.Data.SqlClient.SqlConnection DB_Connect = null;
System.Data.SqlClient.SqlCommand DB_Command = null;
System.Data.SqlClient.SqlTransaction DB_Transaction = null;
int DB_ComRet = 0;
string SqlString = string.Empty;
int i = 0;
int iLen = 0; try
{
DB_Connect = new System.Data.SqlClient.SqlConnection();
DB_Command = new System.Data.SqlClient.SqlCommand();
if (DB_Connect.State == ConnectionState.Closed)
{
DB_Connect.ConnectionString = _DB_ConnStr;
        DB_Connect.Open();
}

DB_Command.Connection = DB_Connect;
DB_Transaction = DB_Connect.BeginTransaction();
DB_Command.Transaction = DB_Transaction;

iLen = SqlStr.Length;
for (i = 0; i <= iLen - 1; i++)
{
SqlString = SqlStr[i].Trim();
if (SqlString != string.Empty)
{
DB_Command.CommandText = SqlString;
DB_Command.CommandType = CommandType.Text;
DB_Command.Prepare();
DB_ComRet = DB_Command.ExecuteNonQuery();
                                                mEffectRecCount += DB_ComRet;
}
}

DB_Transaction.Commit();
return true;
}
catch (SqlException ex)
{
DB_Transaction.Rollback();
                                MsgBoxMsg = ex.ToString();
                                MsgBoxTle = "SQL Server Error";
                                MessageBox.Show(MsgBoxMsg, MsgBoxTle, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
finally
{
if (DB_Connect.State == ConnectionState.Open)
{
DB_Connect.Close();
DB_Connect.Dispose();
}
DB_Connect = null;
DB_Command = null;
}
}