Aegis.Data.MySQL.DBConnector.Connect C# (CSharp) Метод

Connect() публичный Метод

public Connect ( string hostIp, int hostPortNo, string charSet, string dbName, string user, string pwd, int commandTimeoutSec = 60 ) : void
hostIp string
hostPortNo int
charSet string
dbName string
user string
pwd string
commandTimeoutSec int
Результат void
        public void Connect(string hostIp, int hostPortNo, string charSet, string dbName, string user, string pwd, int commandTimeoutSec = 60)
        {
            if (Connection != null)
                return;

            QPS = new IntervalCounter(1000);
            Connection = new MySqlConnection(string.Format("Server={0};Port={1};CharSet={2};Database={3};Uid={4};Pwd={5};"
                                            , hostIp, hostPortNo, charSet, dbName, user, pwd));
            Connection.Open();

            /*using (DBCommand cmd = DBCommand.NewCommand(MySql))
            {
                cmd.QueryNoReader("set transaction isolation level read uncommitted;");
                cmd.QueryNoReader("set session wait_timeout=604800;set session interactive_timeout=604800;");
            }*/
        }

Usage Example

Пример #1
0
        public void Initialize(String ipAddress, Int32 portNo, String charSet, String dbName, String userId, String userPwd)
        {
            if (_cancelTasks != null)
                throw new AegisException(AegisResult.AlreadyInitialized);


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


            IpAddress = ipAddress;
            PortNo = portNo;
            CharSet = charSet;
            DBName = dbName;
            UserId = userId;
            UserPwd = userPwd;


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