Exemplo n.º 1
0
        SetDSNType(DSNType enuType)
        {
            RegistryKey rk = null;

            try
            {
                switch (enuType)
                {
                case DSNType.System_DSN:
                    rk = Registry.LocalMachine;
                    break;

                case DSNType.User_DSN:
                    rk = Registry.CurrentUser;
                    break;

                default: rk = Registry.CurrentUser;
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
            return(rk);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether the specific DSN is exist in ODBC Data Sources.
        /// </summary>
        /// <param name="strDSN"> Name of the DSN.</param>
        /// <param name="enuType">The specific type of the DSN.</param>
        /// <returns>True if the specific DSN is exist.</returns>
        ///
        public Boolean isExist(String strDSN, DSNType enuType)
        {
            RegistryKey rk      = null;
            Boolean     isExist = false;

            try
            {
                rk = SetDSNType(enuType);
                {
                    if (isRegExist(rk.Name + "\\SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources\\",
                                   strDSN))
                    {
                        isExist = true;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
            return(isExist);
        }
 internal ODBCDataSource(string name, string driver, DSNType dsnType)
 {
     this._name    = name;
     this._driver  = driver;
     this._dsnType = dsnType;
 }