예제 #1
0
 /// <summary>
 /// 执行命令,返回受影响的行数.
 /// </summary>
 /// <param name="command">待执行的命令.</param>
 /// <returns></returns>
 public static int STA_ExecuteNounery(string command, IDatabase _database = null)
 {
     if (_database != null)
     {
         return _database.ExecuteNonQuery(command);
     }
     else
     {
         return DataBaseCluster.Get_WRITE_SERVER().ExecuteNonQuery(command);
     }
 }
예제 #2
0
        public static IDatabase CopyDatabase(IDatabase _database)
        {
            DatabaseFactory.initDatabaseType();
            DatabaseType Dbtype = _database.dbType;
            Type type = AllDatabaseFunction[Dbtype];
            IDatabase database = Activator.CreateInstance(type, new object[] { _database.DBServerName }) as IDatabase;
            database.dbType = Dbtype;
            database.connectionString = _database.connectionString;
            database.DBServerName = _database.DBServerName;
            // 主要供事务使用,这里不用自动提交 。
            database.autoCommit = false;

            return database;
        }
예제 #3
0
 public static baseExpert New(Type tp, IDatabase _database)
 {
     baseExpert be = (baseExpert)Activator.CreateInstance(tp);
     be.setDatabase(_database);
     return be;
 }
예제 #4
0
 public void setDatabase(IDatabase _database)
 {
     database = _database;
     autoCommit = false;
 }
예제 #5
0
 public static object STA_ExecuteScalar(string command, List<DbParameter> parameters, IDatabase _database = null)
 {
     if (_database != null)
     {
         return _database.ExecuteScalar(command, parameters);
     }
     else
     {
         return DataBaseCluster.Get_WRITE_SERVER().ExecuteScalar(command, parameters);
     }
 }