Open() public method

��SQL Server����
public Open ( ) : void
return void
コード例 #1
0
 public bool Connect()
 {
     if (!this.isconnected)
     {
         if (db.State == ConnectionState.Open)
         {
             this.isconnected = true; return(true);
         }
         try
         {
             db.Open();
         }
         catch (Exception) { }
         if (db != null)
         {
             if (db.State != ConnectionState.Closed)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     return(true);
 }
コード例 #2
0
 public MSSQLUserDB(string host, int port, string database, string user, string pass)
 {
     this.host        = host;
     this.port        = port;
     this.user        = user;
     this.pass        = pass;
     this.database    = database;
     this.isconnected = false;
     try
     {
         db         = new MSSQLOperator(string.Format("Server={1};Uid={2};Pwd={3};Database={0};", database, host, user, pass));
         dbinactive = new MSSQLOperator(string.Format("Server={1};Uid={2};Pwd={3};Database={0};", database, host, user, pass));
         db.Open();
     }
     catch (Exception ex)
     {
         Logger.ShowSQL("Connction fails, connection string:" + string.Format("Server={1};Uid={2};Pwd={3};Database={0};", database, host, user, pass), null);
         Logger.ShowSQL(ex, null);
     }
     if (db != null)
     {
         if (db.State != ConnectionState.Closed)
         {
             this.isconnected = true;
         }
         else
         {
             Console.WriteLine("SQL Connection error");
         }
     }
 }
コード例 #3
0
ファイル: MSSQLActorDB.cs プロジェクト: Willyham/SagaRO2
 public MSSQLCharacterDB( string host, int port, string database, string user, string pass )
 {
     this.host = host;
     this.port = port.ToString();
     this.dbuser = user;
     this.dbpass = pass;
     this.database = database;
     this.isconnected = false;
     try
     {
         db = new MSSQLOperator(string.Format("Server={1};Uid={2};Pwd={3};Database={0};", database, host, user, pass));
         dbinactive = new MSSQLOperator(string.Format("Server={1};Uid={2};Pwd={3};Database={0};", database, host, user, pass));
         db.Open();
     }
     catch (Exception ex)
     {
         Logger.ShowSQL("Connction fails, connection string:" + string.Format("Server={1};Uid={2};Pwd={3};Database={0};", database, host, user, pass), null);
         Logger.ShowSQL(ex, null);
     }
     if( db != null ) { if( db.State != ConnectionState.Closed )this.isconnected = true; else { Console.WriteLine( "SQL Connection error" ); } }
 }