예제 #1
0
        /// <summary>
        /// Reset button event handler.
        /// Discard the existing mappings in the datagrid and
        /// build a new set from the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonReset_Click(object sender, System.EventArgs e)
        {
            if (this.dbAdapter == null)
            {
                System.Windows.Forms.MessageBox.Show(
                    "Data Adapter is null; Table mappings is not available.",
                    "Table Mappings");
                return;
            }

            DataTableMappingCollection mapList = this.dbAdapter.TableMappings;

            if (mapList == null)
            {
                System.Windows.Forms.MessageBox.Show(
                    "Data Adapter's Table mappings are null and are not available.",
                    "Table Mappings");
                return;
            }

            System.Data.DataTable dt;
            dt = TableMappings.BuildMapFromDatabase(
                DataAdapterUtil.GetDataAdapterClone(this.dbAdapter));
            textBoxDatasetTable.Text =
                TableMappings.BuildDataSetNameFromCommand(this.dbAdapter);

            dt.AcceptChanges();
            this.dataGrid1.DataSource = dt;
        }  // buttonReset_Click
예제 #2
0
        //public DataAdapterWizard() : this(new IngresDataAdapter(), null)
        //{
        //}

        public DataAdapterWizard(
            IngresDataAdapter adapter,
            System.ComponentModel.Design.IDesignerHost host)
        {
            Form dlgWelcome = new DataAdapterWizardWelcomeForm();
            DataAdapterWizardGenerateForm dlgGenerate = null;
            DialogResult result = DialogResult.OK;

            //goto debugLabel;
ShowWelcome:
            result = dlgWelcome.ShowDialog();
            if (result == DialogResult.Cancel)             // if Cancel button, return
            {
                return;
            }
            //debugLabel:
            ConnectionEditor connectionEditor =
                new ConnectionEditor(adapter, host);

            if (dlgGenerate == null)
            {
                dlgGenerate =
                    new DataAdapterWizardGenerateForm(adapter.SelectCommand);
            }

            //ShowGenerate:
            result = dlgGenerate.ShowDialog();
            if (result == DialogResult.Cancel)             // if Cancel button, return
            {
                return;
            }
            // update the SelectCommand with the entry from the form's text
            if (result == DialogResult.Retry)              // if Back button, go back one
            {
                goto ShowWelcome;
            }

            adapter.SelectCommand.CommandText = dlgGenerate.CommandText;

            try
            {
                TableMappings.Generate(adapter);
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Could not generate DataAdapter's TableMappings.\n" +
                    ex.Message,
                    "Data Adapter Wizard");
            }
        }