Exemplo n.º 1
0
        //int MAX_RETRY_COUNT = 5;

        public Database()
        {
            connection = new Connection();

            try
            {
                conectionSettings = connectionProvider.getConnectionParameters();
            }
            catch (Exception)
            {
                frmDBAyarlar frm = new frmDBAyarlar();
                frm.ShowDialog();
                frm.Dispose();
                conectionSettings = connectionProvider.getConnectionParameters();
            }

            if (conectionSettings.dbType == "ORACLE")
            {
                connection.DatabaseType = Enums.DbTypes.ORACLE;
            }
            else
            {
                connection.DatabaseType = Enums.DbTypes.MSSQL;
            }
        }
Exemplo n.º 2
0
        public static OdbcConnection getODBCConnection()
        {
            OdbcConnection connec = null;

            try
            {
                ConnectionSettings settings = LoadDbConnectionSettings();
                if (String.IsNullOrEmpty(settings.dsn))
                {
                    frmDBAyarlar frm = new frmDBAyarlar();
                    frm.ShowDialog();
                    frm.Dispose();
                    getODBCConnection();
                }
                string constr = "DSN=" + settings.dsn + ";UID=" + settings.uid + ";PWD=" + settings.pwd + ";";
                connec = new OdbcConnection(constr);
                connec.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Connection Error: " + ex.Message);
            }
            return(connec);
        }