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

GetSchema() public method

Returns schema information for the data source of this DbConnection using the specified string for the schema name and the specified string array for the restriction values.
public GetSchema ( string collectionName, string restrictionValues ) : DataTable
collectionName string Specifies the name of the schema to return.
restrictionValues string Specifies a set of restriction values for the requested schema.
return System.Data.DataTable
        public override DataTable GetSchema(string collectionName, string[] restrictionValues)
        {
            if (collectionName == null)
                collectionName = SchemaProvider.MetaCollection;

            string[] restrictions = schemaProvider.CleanRestrictions(restrictionValues);
            DataTable dt = schemaProvider.GetSchema(collectionName, restrictions);
            return dt;
        }

Same methods

MySqlConnection::GetSchema ( ) : DataTable
MySqlConnection::GetSchema ( string collectionName ) : 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