getSchema with Universal adapter and MySQL

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for universal data access
Post Reply
Posts: 1
Joined: Tue 06 Mar 2012 23:58

getSchema with Universal adapter and MySQL

Post by Bigpoint99 » Wed 07 Mar 2012 00:51


I want to retrieve all tables of a MySqL Datbase. But the following code delivers only an empty DataTable with MySQL 5.1. It works fine with MS SQL.


Code: Select all

private void GetTableData(Provider prov, string datasource, string database, int port, string userId, string password)
            Devart.Data.Universal.UniConnection uc = new Devart.Data.Universal.UniConnection();
            uc.Provider = prov.ToString().Replace("_", " ");  
            uc.DataSource = datasource;
            uc.Database = database;
            uc.UserId = userId;
            uc.Password = password;

            this.dtTables = uc.GetSchema("Tables");

Devart Team
Posts: 2101
Joined: Wed 02 Nov 2011 09:44

Post by Pinturiccio » Mon 12 Mar 2012 12:54

UniConnection.GetSchema method is overloaded. When you use GetSchema("Tables"), this method will return a list of tables from the 'mysql' database regardless of the database, specified in the connection. If your UserId does not have access to the 'mysql' database, you will retrieve an empty table.
So, if you want retrieve a list of tables from some database, then you should use Getschema(string, string[]) method. The second parameters is the array of restrictions. For example, if you want retrieve metadata from the test database (and your user account has permissions to access the test database) use the following code:

Code: Select all

this.dtTables = uc.GetSchema("Tables", new string[] { "test" } );
For more information please refer to ... #getschema

Post Reply