private void frmDefineODBC_Load(object sender, EventArgs e)
        {
            sources = OdbcWrapper.ListODBCsources();

            int selectedIndex = -1;

            foreach (OdbcSource dsn in sources)
            {
                int index = comboBoxDSN.Items.Add(dsn.ServerName);
                if (dsn.ServerName == Config.Sets.Primary_ODBC_DSN)
                {
                    selectedIndex = index;
                }
            }

            if (selectedIndex >= 0)
            {
                comboBoxDSN.SelectedIndex = selectedIndex;
            }
            else
            {
                comboBoxDSN.Text = Config.Sets.Primary_ODBC_DSN;
            }

            textBoxUserName.Text = Config.Sets.Primary_ODBC_User;
            textBoxPassword.Text = Config.Sets.Primary_ODBC_Pass;

            UpdateConfigState(Config.State);
            Config.StateChange += ConfigStateChange;
        }
Esempio n. 2
0
        public void CreateRecordInDatabase(DbRecord dbRecord)
        {
            string createQuery          = BuildCreateString(dbRecord);
            var    odbcColumnParameters = dbRecord.Values.Select(t => new OdbcParameter(t.Key, t.Value)).ToArray();

            using (OdbcWrapper odbcWrapper = new OdbcWrapper(connection.GetConnection() as OdbcConnection))
            {
                odbcWrapper.ExecuteNonQuery(createQuery, odbcColumnParameters);
            }
        }
Esempio n. 3
0
        public void UpdateRecordInDatabase(DbRecord dbRecord)
        {
            string updateQuery          = BuildUpdateString(dbRecord);
            var    odbcColumnParameters = dbRecord.Values.Select(t => new OdbcParameter(t.Key, t.Value)).ToArray();
            var    odbcWhereParameters  = dbRecord.Identifiers.Select(t => new OdbcParameter(t.Key, t.Value)).ToArray();

            using (OdbcWrapper odbcWrapper = new OdbcWrapper(connection.GetConnection() as OdbcConnection))
            {
                odbcWrapper.ExecuteNonQuery(updateQuery, odbcColumnParameters.Concat(odbcWhereParameters).ToArray());
            }
        }
Esempio n. 4
0
        public List <object[]> ResolveRecordInDatabase(DbRecord dbRecord)
        {
            List <object[]> result = new List <object[]>();

            string query          = BuildResolverQuery(dbRecord.TableName, dbRecord.Identifiers);
            var    odbcParameters = dbRecord.Identifiers.Select(t => new OdbcParameter(t.Key, t.Value)).ToArray();

            using (OdbcWrapper odbcWrapper = new OdbcWrapper(connection.GetConnection() as OdbcConnection))
            {
                var odbcReader = odbcWrapper.ExecuteQuery(query, odbcParameters);
                while (odbcReader.Read())
                {
                    var row = odbcWrapper.ReadCurrentRow(odbcReader);
                    result.Add(row);
                }
            }

            return(result);
        }