MySql.Data.MySqlClient.MySqlConnection.GetSchema C# (CSharp) Method

GetSchema() public method

Returns schema information for the data source of this DbConnection.
public GetSchema ( ) : DataTable
return System.Data.DataTable
        public override DataTable GetSchema()
        {
            return GetSchema(null);
        }

Same methods

MySqlConnection::GetSchema ( string collectionName ) : DataTable
MySqlConnection::GetSchema ( string collectionName, string restrictionValues ) : DataTable

Usage Example

 public bool ConnectToDataBase(string strConnect)
 {
     sqlConnection = new MySqlConnection(strConnect.ToString());
     try
     {
         sqlConnection.Open();
         listTables = new List<string>();
         using (DataTable dt = sqlConnection.GetSchema("Tables"))
         {
             if (dt != null && dt.Rows.Count > 0)
             {
                 listTables.Capacity = dt.Rows.Count;
                 foreach (DataRow row in dt.Rows)
                     listTables.Add(row["table_name"].ToString());
             }
         }
         sqlConnection.Close();
         //string query = "select * from sys.tables where type_desc = 'USER_TABLE'";
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message);
         return false;
     }
     return true;
 }
All Usage Examples Of MySql.Data.MySqlClient.MySqlConnection::GetSchema