示例#1
0
        private bool _SqlConnectStatus()
        {
            //string ConnetionString = string.Format(@"Data Source={0};Initial Catalog={1};User ID={2};Password={3}",
            //       MainDB_DataSource,MainDB_DataBaseName,MainDB_UserID,MainDB_Password);
            try
            {
                string DataSource   = MainDB_DataSource;
                string DataBaseName = MainDB_DataBaseName;
                string UserID       = MainDB_UserID;
                string Password     = MainDB_Password;

                if (__Encrypt)
                {
                    __Dek             = new Decrypt();
                    __Dek.DecryptCode = __Key;
                    DataSource        = __Dek.GetDecryptHashCode(MainDB_DataSource);
                    DataBaseName      = __Dek.GetDecryptHashCode(MainDB_DataBaseName);
                    UserID            = __Dek.GetDecryptHashCode(MainDB_UserID);
                    Password          = __Dek.GetDecryptHashCode(MainDB_Password);
                }
                SqlConnectionStringBuilder s = new SqlConnectionStringBuilder();
                //s.Encrypt = true;
                if (ConnectionStringEnable)
                {
                    con = new SqlConnection(ConnectionString);
                }
                else
                {
                    s.DataSource         = DataSource;
                    s.InitialCatalog     = DataBaseName;
                    s.UserID             = UserID;
                    s.Password           = Password;
                    s.IntegratedSecurity = true;
                    string ConncetionString = string.Format(@"Data Source={0};Initial Catalog={1};User ID={2};Password={3}", DataSource, DataBaseName, UserID, Password);
                    con = new SqlConnection(ConncetionString);
                }
                con.Open();
                if (con.State == ConnectionState.Open)
                {
                    ErrorMessage = "Success"; __SqlConnectionStatus = true; con.Close(); return(true);
                }
                else
                {
                    ErrorMessage = "Failed"; __SqlConnectionStatus = false; con.Close(); return(false);
                }
            }
            catch (Exception er)
            {
                ErrorMessage          = "Connection/" + er.Message;
                __SqlConnectionStatus = false;
                return(false);
            }
        }
示例#2
0
        private bool _MySqlConnectionStatus()
        {
            try
            {
                string DataSource   = _DataSource;
                string Port         = _Port;
                string UserName     = _UserName;
                string Password     = _Password;
                string DatabaseName = _DatabaseName;

                if (__Encrypt)
                {
                    __Dek             = new Decrypt();
                    __Dek.DecryptCode = __Key;
                    DataSource        = __Dek.GetDecryptHashCode(_DataSource);
                    Port         = __Dek.GetDecryptHashCode(_Port);
                    UserName     = __Dek.GetDecryptHashCode(_UserName);
                    Password     = __Dek.GetDecryptHashCode(_Password);
                    DatabaseName = __Dek.GetDecryptHashCode(_DatabaseName);
                }
                if (ConncetionStringEnable)
                {
                    __Connection = new MySqlConnection(ConnectionString);
                }
                else
                {
                    string MySqlConnectionString = string.Format(@"datasource={0};port={1};username={2};password={3};database={4}",
                                                                 DataSource, Port, UserName, Password, DatabaseName);
                    __Connection = new MySqlConnection(MySqlConnectionString);
                }
                __Connection.Open();
                if (__Connection.State == System.Data.ConnectionState.Open)
                {
                    Message = "Success";
                    __Connection.Close();
                    return(true);
                }
                else
                {
                    Message = "Failed";
                    __Connection.Close();
                    return(false);
                }
            }
            catch (Exception er)
            {
                ExMessage = er;
                Message   = er.Message;
                return(false);
            }
        }
示例#3
0
        public SqlConnection Configuration()
        {
            //--------------------------------------
            // Copy the Encrypt text
            //--------------------------------------
            string DataSource   = MainDB_DataSource;
            string DataBaseName = MainDB_DataBaseName;
            string UserID       = MainDB_UserID;
            string Password     = MainDB_Password;

            if (__Encrypt)// if Encrypt is true that is Decode the program
            {
                __Dek             = new Decrypt();
                __Dek.DecryptCode = __Key;
                //------------------------------------------------
                // that is the decrypt code process and __key is a
                // Decrypt code to plain text.
                //-------------------------------------------------
                DataSource   = __Dek.GetDecryptHashCode(MainDB_DataSource);
                DataBaseName = __Dek.GetDecryptHashCode(MainDB_DataBaseName);
                UserID       = __Dek.GetDecryptHashCode(MainDB_UserID);
                Password     = __Dek.GetDecryptHashCode(MainDB_Password);
            }
            SqlConnectionStringBuilder s = new SqlConnectionStringBuilder();

            // s.Encrypt = true;
            if (ConnectionStringEnable)
            {
                SqlConnection cc = new SqlConnection(ConnectionString);
                return(cc);
            }
            else
            {
                s.DataSource         = DataSource;
                s.InitialCatalog     = DataBaseName;
                s.UserID             = UserID;
                s.Password           = Password;
                s.IntegratedSecurity = true;
                string        ConncetionString = string.Format(@"Data Source={0};Initial Catalog={1};User ID={2};Password={3}", DataSource, DataBaseName, UserID, Password);
                SqlConnection cc = new SqlConnection(ConncetionString);
                return(cc);
            }

            //----------------------------------------------------
            //All are ok then SqlConnection is return to Excutive
            //----------------------------------------------------
        }
示例#4
0
        private MySqlConnection _Configuration()
        {
            try
            {
                string DataSource   = _DataSource;
                string Port         = _Port;
                string UserName     = _UserName;
                string Password     = _Password;
                string DatabaseName = _DatabaseName;

                if (__Encrypt)
                {
                    __Dek             = new Decrypt();
                    __Dek.DecryptCode = __Key;
                    DataSource        = __Dek.GetDecryptHashCode(_DataSource);
                    Port         = __Dek.GetDecryptHashCode(_Port);
                    UserName     = __Dek.GetDecryptHashCode(_UserName);
                    Password     = __Dek.GetDecryptHashCode(_Password);
                    DatabaseName = __Dek.GetDecryptHashCode(_DatabaseName);
                }
                if (ConncetionStringEnable)
                {
                    __Connection = new MySqlConnection(ConnectionString);
                }
                else
                {
                    string MySqlConnectionString = string.Format(@"datasource={0};port={1};username={2};password={3};database={4}",
                                                                 DataSource, Port, UserName, Password, DatabaseName);
                    __Connection = new MySqlConnection(MySqlConnectionString);
                }
                Message = "Success";
            }
            catch (Exception er)
            {
                ExMessage = er;
                Message   = er.Message;
            }
            return(__Connection);
        }