Page 1 of 1

getSchema with Universal adapter and MySQL

Posted: Wed 07 Mar 2012 00:51
by Bigpoint99
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();
        }

Posted: Mon 12 Mar 2012 12:54
by Pinturiccio
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