Aegis.Data.MSSQL.DBConnector.Connect C# (CSharp) Method

Connect() public method

public Connect ( string host, string userId, string userPwd, string dbName ) : void
host string
userId string
userPwd string
dbName string
return void
        public void Connect(string host, string userId, string userPwd, string dbName)
        {
            if (Connection != null)
                return;

            QPS = new IntervalCounter("", 1000);
            Connection = new SqlConnection(string.Format("server={0};uid={1};pwd={2};database={3};", host, userId, userPwd, dbName));
            Connection.Open();
        }

Usage Example

Example #1
0
        public void Initialize(String host, String userId, String userPwd, String dbName)
        {
            if (_cancelTasks != null)
                throw new AegisException(AegisResult.AlreadyInitialized);


            //  Connection Test
            try
            {
                DBConnector dbc = new DBConnector();
                dbc.Connect(host, userId, userPwd, dbName);
                dbc.Close();
            }
            catch (Exception e)
            {
                throw new AegisException(AegisResult.MySqlConnectionFailed, e, "Invalid MySQL connection.");
            }


            HostAddress = host;
            UserId = userId;
            UserPwd = userPwd;
            DBName = dbName;


            _cancelTasks = new CancellationTokenSource();
        }
All Usage Examples Of Aegis.Data.MSSQL.DBConnector::Connect