Ejemplo n.º 1
0
        protected override void PopulateDb(dba odbcDba)
        {
            tblTestRow [] rows = new tblTestRow [] {
                new tblTestRow(1, "Number one."),
                new tblTestRow(2, "Number two."),
                new tblTestRow(3, "Number three.")
            };

            odbcDba.ExecuteSqlCommand(_sqlCreateTable);

            foreach(tblTestRow row in rows) {
                OdbcParameter[] parameters = new OdbcParameter [] {
                    new OdbcParameter("@idParam", row.Id),
                    new OdbcParameter("@descriptionParam", row.Description)
                };
                odbcDba.ExecuteSqlCommand(_sqlInsertRow, parameters);
            }
            string [] columnData = odbcDba.GetColumnAsStringArray("tblTest", "description");
            Assert.AreEqual(columnData.Length, 3, "Inserted 3 rows and retrieved {0}", new object[] {columnData.Length});
        }
Ejemplo n.º 2
0
 protected abstract void PopulateDb(dba dataAccessor);
Ejemplo n.º 3
0
        internal void OpenMDB(string FileName)
        {
            DialogResult Result;

            this._dbcon = new OleDba();

            try {
                ((OleDba) _dbcon).ConnectMDB(FileName);
            } catch (OleDbException ex) {
                //TODO: this is the error code for incorrect access password. Make this a constant.
                if (ex.ErrorCode == -2147217843) {
                    InputDialog GetPassword = new InputDialog();
                    Result = GetPassword.ShowDialog("Enter the password for the database");
                    if (Result == DialogResult.OK) {
                        try {
                            ((OleDba) _dbcon).ConnectMDB(FileName, GetPassword.Input);
                        } catch (OleDbException exSecond) {
                            if (exSecond.ErrorCode == -2147217843) {
                                MessageBox.Show("Incorrect Password");
                            } else {
                                throw exSecond;
                            }
                            return;
                        } finally { GetPassword.Dispose(); }
                    }
                } else if (ex.ErrorCode == -2147467259) {
                    Text = "PlaneDisaster.NET";
                    //TODO: Apparently this error code is also returned if you try to open an .accdb with the Jet 4.0 driver
                    string Msg = String.Format("File [{0}] not found.", FileName);
                    MessageBox.Show(Msg, "Error Opening File");
                    return;
                } else {
                    throw ex;
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message, "Error Opening database");
                return;
            }
            Text = string.Format("{0} - ({1}) - PlaneDisaster.NET", Path.GetFileName(FileName), FileName);
             		    CurrentFile = FileName;
            this.DisplayDataSource();
        }
Ejemplo n.º 4
0
        internal void OpenSQLite(string FileName)
        {
            this._dbcon = new SQLiteDba();

            ((SQLiteDba) _dbcon).Connect(FileName);
            Text = string.Format("{0} - ({1}) - PlaneDisaster.NET", System.IO.Path.GetFileName(FileName), FileName);

            CurrentFile = FileName;
            this.DisplayDataSource();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Disconnects from the data source and updates the GUI appropiatly.
        /// </summary>
        internal void DisconnectDataSource()
        {
            /* ListBox Double Click event handlers */
            lstColumns.DoubleClick -= lst_DblClick;
            lstProcedures.DoubleClick -= this.lst_DblClick;
            lstTables.DoubleClick -= lst_DblClick;
            lstViews.DoubleClick -= lst_DblClick;

            lstProcedures.DataSource = null;
            lstTables.DataSource = null;
            lstViews.DataSource = null;
            /*
             * We must clear this last otherwise, events firing from
             * the first three might repopulate this.
             */
            lstColumns.DataSource = null;

            lstColumns.ContextMenu = null;
            lstProcedures.ContextMenu = null;
            lstTables.ContextMenu = null;
            lstViews.ContextMenu = null;

            txtResults.Text = "";
            CSV = "";
            gridResults.DataSource = null;

            databaseSchemaToolStripMenuItem.Enabled = false;
            _dbcon.Disconnect();
            _dbcon = null;
            Text = "PlaneDisaster.NET";
            databaseSchemaToolStripMenuItem.Enabled = false;
            closeToolStripMenuItem.Enabled = false;
            queryToolStripMenuItem.Enabled = false;
            cmdRefresh.Enabled = false;
            CurrentFile = null;
        }