MySqlCommand and CommandBehavior.SchemaOnly
Posted: 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:
And after this, i read the datatable with code like
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
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();
}
}
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();
- 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
