コード例 #1
0
ファイル: Form1.cs プロジェクト: DavidARS/WaterSim_5
 private void ToolStripMenuItemGetTables_Click(object sender, EventArgs e)
 {
     if (MyUniDbConnection != null)
     {
         if (MyUniDbConnection.State == ConnectionState.Open)
         {
             bool          isError    = false;
             string        errMessage = "";
             List <string> TheNames   = MyUniDbConnection.GetTableNames(ref isError, ref errMessage);
             listBox1.Items.Clear();
             foreach (string table in TheNames)
             {
                 listBox1.Items.Add(table);
             }
         }
     }
 }
コード例 #2
0
        //-----------------------------------------------------------------

        ///-------------------------------------------------------------------------------------------------
        /// <summary> Shows the dialog in dialog mode. </summary>
        ///
        /// <remarks>  </remarks>
        ///
        /// <param name="Connection">    The OlDbConnection. </param>
        /// <param name="RequireUnique"> true to require unique tablename. </param>
        /// <param name="MustExist">     true if tablename must exist. </param>
        ///
        /// <returns> . </returns>
        ///-------------------------------------------------------------------------------------------------

        public DialogResult ShowDialog(UniDbConnection Connection, bool RequireUnique, bool MustExist)
        {
            bool   iserror    = true;
            string ErrMessage = "";

            _dbConnect             = Connection;
            orgOpen                = (_dbConnect.State == System.Data.ConnectionState.Open);
            RequireUniqueTablename = RequireUnique;
            TablenameMustExist     = MustExist;
            try
            {
                if (!orgOpen)
                {
                    _dbConnect.Open();
                }
                TablenameComboBox.Items.Clear();
                _tablenames.Clear();
                DataSetInfoLabel.Text = _dbConnect.DataSource.ToString();
                _tablenames           = _dbConnect.GetTableNames(ref iserror, ref ErrMessage);
                foreach (string str in _tablenames)
                {
                    TablenameComboBox.Items.Add(str);
                }
                //DataTable dbSchema = new DataTable();
                //dbSchema = _dbConnect.GetSchema("TABLES");
                //for (int i = 0; i < dbSchema.Rows.Count; i++)
                //{
                //    if (dbSchema.Rows[i]["TABLE_TYPE"].ToString() == "TABLE")
                //    {
                //        temp = dbSchema.Rows[i]["TABLE_NAME"].ToString();
                //         TablenameComboBox.Items.Add(temp);
                //         _tablenames.Add(temp);
                //    }
                //}
                return(ShowDialog());
            }
            catch (Exception)
            {
                return(DialogResult.Abort);
            }
        }