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); }
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"); } } }
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" ); } } }