コード例 #1
0
        public bool initiateDBConnection(string serverName, string dbName, string userName, string password)
        {
            string connectionString = "Server = " + serverName + ";Uid = " + userName + ";Database = " + dbName + "; Pwd =" + password + "";

            DBConnService = new DBConnectionService(connectionString);

            try{
                DBConnService.OpenConnection();
                DBConnService.Count("select count(id) from sms_modem");

                Properties.Settings.Default.Server           = serverName;
                Properties.Settings.Default.DBName           = dbName;
                Properties.Settings.Default.UserName         = userName;
                Properties.Settings.Default.Password         = password;
                Properties.Settings.Default.ConnectionString = connectionString;
                Properties.Settings.Default.Save();

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
        }
コード例 #2
0
        public bool chekcDBConnection()
        {
            DBConnService  = new DBConnectionService(Properties.Settings.Default.ConnectionString);
            DBConnService2 = new DBConnectionService(Properties.Settings.Default.ConnectionString2);
            try
            {
                //DBConnService.OpenConnection();

                //DBConnService.CloseConnection();
                var data = DBConnService.Count("SELECT count(id)  From sms_modem ");
                DBConnService2.OpenConnection();
                DBConnService2.CloseConnection();
                return(true);
            } catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
        }