MySqlCommand and CommandBehavior.SchemaOnly

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
AI
Posts: 3
Joined: Mon 03 Aug 2009 14:06

MySqlCommand and CommandBehavior.SchemaOnly

Post by AI » Mon 03 Aug 2009 14:29

I have the need to retrieve the original mysql datatypes dinamically when i read a mysqldatatable at runtime.

So far, I've been doing something like this just before reading the table:

Code: Select all

                                
using (MySqlCommand cmd = new MySqlCommand(sqltext, connection) { FetchAll = false })
{
    using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly))
    {
        for (int i = 0; i < reader.FieldCount; i++)
        {
            String fld = reader.GetDataTypeName(i);
            .....
        }
        reader.Close();
    }
}
And after this, i read the datatable with code like

Code: Select all

MySqlDataTable Result = new MySqlDataTable();
Result.Connection = connection;
Result.FetchAll = true;
Result.SelectCommand = new MySqlCommand(sqltext);
Result.StartRecord = 0;
Result.MaxRecords = 20;
Result.Open();
About this, just one question:
- is there any way to get the datatypename informations directly from the MySqlDataTable instead than having to run the code above also ?

Thanks in advance :)

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 06 Aug 2009 07:40

There is no way to obtain the source type information without woking with DataReader in the current version.
We will implement the SchemaTable property in the future release.

AI
Posts: 3
Joined: Mon 03 Aug 2009 14:06

Post by AI » Thu 06 Aug 2009 08:01

Allright, thanks!

Post Reply