示例#1
0
 public int ExecuteSql(string sql, DbParameter[] parameter)
 {
     using (var conn = CreateConnection())
     {
         try
         {
             conn.Open();
             using (var dbCommand = conn.CreateCommand())
             {
                 dbCommand.CommandText = sql;
                 parameter.ToList().ForEach(item =>
                 {
                     _db.AddInParameter(dbCommand, item.ParameterName, item.DbType, item.Value);
                 });
                 dbCommand.CommandType = CommandType.Text;
                 return dbCommand.ExecuteNonQuery();
             }
         }
         finally
         {
             conn.Close();
             conn.Dispose();
         }
     }
 }