コード例 #1
0
ファイル: vstablemap.cs プロジェクト: GunterMueller/Ingres
        }          // BuildDataSetNameFromCommand(DbDataAdapter dbAdapter)

        static internal string BuildDataSetNameFromCommand(
            string cmdText)
        {
            if (cmdText == null ||
                cmdText.Length == 0)
            {
                return("Table");
            }

            try
            {
                // Scan the SELECT statment,
                // set the CmdTokenList token list for the SQL statement, and
                // build the column and table names lists.
                Ingres.ProviderInternals.MetaData md =
                    new Ingres.ProviderInternals.MetaData(cmdText);
                if (md != null &&
                    md.Tables != null &&
                    md.Tables.Count > 0)
                {
                    Ingres.ProviderInternals.MetaData.Table t =
                        (Ingres.ProviderInternals.MetaData.Table)md.Tables[0];
                    return(t.TableName);                     // found it!  return 1st table name
                }
            }
            catch (FormatException) // catch invalid syntax; i.e. no SELECT
            {}
            return("Table");        // no SELECT stmt or tables; default to "Table"
        }
コード例 #2
0
ファイル: vsgendataset.cs プロジェクト: GunterMueller/Ingres
        private void GenDataSetForm_Load(object sender, System.EventArgs e)
        {
            if (dte == null)
            {
                MessageBox.Show(
                    "Visual Studio .NET DTE could not be found.");
                return;
            }

            if (dte.ActiveDocument == null ||
                dte.ActiveDocument.ProjectItem == null ||
                dte.ActiveDocument.ProjectItem.ContainingProject == null)
            {
                MessageBox.Show(
                    "Visual Studio .NET current project could not be found.");
                return;
            }

            currentProject         = dte.ActiveDocument.ProjectItem.ContainingProject;
            currentProjectFullPath =
                GetProperty(currentProject.Properties, "FullPath");
            if (currentProjectFullPath.Length == 0 ||
                !System.IO.Directory.Exists(currentProjectFullPath))
            {
                MessageBox.Show(
                    "Visual Studio .NET current project directory " +
                    "\"" + currentProjectFullPath + "\"" +
                    "could not be found.");
                return;
            }
            currentProjectNamespace =
                GetProperty(currentProject.Properties, "RootNamespace");
            if (currentProjectNamespace.Length == 0)
            {
                currentProjectNamespace =
                    GetProperty(currentProject.Properties, "DefaultNamespace");
            }

            existingDataSetProjectItems =
                GetAllDataSetsInProjectItems(
                    new ArrayList(), currentProject.ProjectItems);

            existingDataSetNames =
                GetProjectItemsNames(existingDataSetProjectItems);

            this.comboBoxExisting.DataSource = existingDataSetNames;

            this.textBoxNew.Text = CreateUniqueDataSetName();


            tableNames = new StringCollection();

            string         tableName      = "Table";
            IDbDataAdapter idbDataAdapter = this.dbDataAdapter as IDbDataAdapter;

            if (idbDataAdapter == null ||
                idbDataAdapter.SelectCommand == null ||
                idbDataAdapter.SelectCommand.CommandText == null ||
                idbDataAdapter.SelectCommand.CommandText.Length == 0)
            {
                MessageBox.Show("Adapter's SelectCommand is not configured",
                                "Generate " + DATASETNAME_PREFIX);
                return;
            }

            string cmdText = idbDataAdapter.SelectCommand.CommandText;

            try
            {
                // Scan the SELECT statment,
                // set the CmdTokenList token list for the SQL statement, and
                // build the column and table names lists.
                Ingres.ProviderInternals.MetaData md =
                    new Ingres.ProviderInternals.MetaData(cmdText);
                if (md != null &&
                    md.Tables != null &&
                    md.Tables.Count > 0)
                {
                    Ingres.ProviderInternals.MetaData.Table t =
                        (Ingres.ProviderInternals.MetaData.Table)md.Tables[0];
                    tableName = t.TableName;
                }
            }
            catch (FormatException)             // catch invalid syntax
            {
                MessageBox.Show("Adapter's SelectCommand is not valid syntax.",
                                "Generate " + DATASETNAME_PREFIX);
                return;
            }
            Component component = (Component)this.dbDataAdapter;

            tableName = tableName + " (" + component.Site.Name + ")";
            this.checkedListBoxTables.Items.Add(tableName, CheckState.Checked);

            // we're good to go; activate controls
            if (existingDataSetProjectItems.Count > 0)
            {
                this.radioButtonExisting.Enabled = true;
            }
            this.radioButtonNew.Enabled = true;
            this.radioButtonNew.Checked = true;
            this.buttonOK.Enabled       = true;
            this.buttonOK.Focus(); // set focus to OK button
        }                          // GenDataSetForm_Load
コード例 #3
0
ファイル: vsgendataset.cs プロジェクト: JordanChin/Ingres
        private void GenDataSetForm_Load(object sender, System.EventArgs e)
        {
            if (dte == null)
            {
                MessageBox.Show(
                    "Visual Studio .NET DTE could not be found.");
                return;
            }

            if (dte.ActiveDocument == null  ||
                dte.ActiveDocument.ProjectItem == null  ||
                dte.ActiveDocument.ProjectItem.ContainingProject == null)
            {
                MessageBox.Show(
                    "Visual Studio .NET current project could not be found.");
                return;
            }

            currentProject = dte.ActiveDocument.ProjectItem.ContainingProject;
            currentProjectFullPath =
                GetProperty(currentProject.Properties, "FullPath");
            if (currentProjectFullPath.Length == 0  ||
                !System.IO.Directory.Exists(currentProjectFullPath))
            {
                MessageBox.Show(
                    "Visual Studio .NET current project directory " +
                    "\"" + currentProjectFullPath + "\"" +
                    "could not be found.");
                return;
            }
            currentProjectNamespace=
                GetProperty(currentProject.Properties, "RootNamespace");
            if (currentProjectNamespace.Length == 0)
                currentProjectNamespace=
                    GetProperty(currentProject.Properties, "DefaultNamespace");

            existingDataSetProjectItems =
                GetAllDataSetsInProjectItems(
                    new ArrayList(), currentProject.ProjectItems);

            existingDataSetNames =
                GetProjectItemsNames(existingDataSetProjectItems);

            this.comboBoxExisting.DataSource = existingDataSetNames;

            this.textBoxNew.Text = CreateUniqueDataSetName();

            tableNames = new StringCollection();

            string tableName = "Table";
            IDbDataAdapter idbDataAdapter = this.dbDataAdapter as IDbDataAdapter;
            if (idbDataAdapter == null  ||
                idbDataAdapter.SelectCommand == null  ||
                idbDataAdapter.SelectCommand.CommandText == null ||
                idbDataAdapter.SelectCommand.CommandText.Length == 0)
            {
                MessageBox.Show("Adapter's SelectCommand is not configured",
                    "Generate " + DATASETNAME_PREFIX);
                return;
            }

            string cmdText = idbDataAdapter.SelectCommand.CommandText;
            try
            {
                // Scan the SELECT statment,
                // set the CmdTokenList token list for the SQL statement, and
                // build the column and table names lists.
                Ingres.ProviderInternals.MetaData md =
                    new Ingres.ProviderInternals.MetaData(cmdText);
                if (md        != null  &&
                    md.Tables != null  &&
                    md.Tables.Count > 0)
                {
                    Ingres.ProviderInternals.MetaData.Table t =
                        (Ingres.ProviderInternals.MetaData.Table)md.Tables[0];
                    tableName = t.TableName;
                }
            }
            catch(FormatException)  // catch invalid syntax
            {
                MessageBox.Show("Adapter's SelectCommand is not valid syntax.",
                    "Generate " + DATASETNAME_PREFIX);
                return;
            }
            Component component = (Component)this.dbDataAdapter;
            tableName = tableName + " (" + component.Site.Name + ")";
            this.checkedListBoxTables.Items.Add(tableName, CheckState.Checked);

            // we're good to go; activate controls
            if (existingDataSetProjectItems.Count > 0)
                this.radioButtonExisting.Enabled = true;
            this.radioButtonNew.Enabled      = true;
            this.radioButtonNew.Checked      = true;
            this.buttonOK.Enabled            = true;
            this.buttonOK.Focus();  // set focus to OK button
        }
コード例 #4
0
ファイル: vstablemap.cs プロジェクト: JordanChin/Ingres
        internal static string BuildDataSetNameFromCommand(
			string cmdText)
        {
            if (cmdText == null  ||
                cmdText.Length == 0)
                return "Table";

            try
            {
                // Scan the SELECT statment,
                // set the CmdTokenList token list for the SQL statement, and
                // build the column and table names lists.
                Ingres.ProviderInternals.MetaData md =
                    new Ingres.ProviderInternals.MetaData(cmdText);
                if (md        != null  &&
                    md.Tables != null  &&
                    md.Tables.Count > 0)
                {
                    Ingres.ProviderInternals.MetaData.Table t =
                        (Ingres.ProviderInternals.MetaData.Table)md.Tables[0];
                    return t.TableName;  // found it!  return 1st table name
                }
            }
            catch(FormatException)  // catch invalid syntax; i.e. no SELECT
            {}
            return "Table";  // no SELECT stmt or tables; default to "Table"
        }