getSchema with Universal adapter and MySQL

getSchema with Universal adapter and MySQL

Postby Bigpoint99 » Wed 07 Mar 2012 00:51

Hi,

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.

regards,
chris



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;

            uc.Open();
            this.dtTables = uc.GetSchema("Tables");
            uc.Close();
        }
Bigpoint99
 
Posts: 1
Joined: Tue 06 Mar 2012 23:58

Postby 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 http://www.devart.com/dotconnect/mysql/ ... #getschema
Pinturiccio
Devart Team
 
Posts: 2026
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect Universal