Bug #55823 Add a class MySqlDataTable deriving from System.Data.DataTable
Submitted: 8 Aug 2010 14:12
Reporter: Holger Mueller Email Updates:
Status: Open Impact on me:
None 
Category:Connector / NET Severity:S4 (Feature request)
Version:6.3.3 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: MySqlDataTable DataTable paging background task

[8 Aug 2010 14:12] Holger Mueller
Description:
I would like to suggest to offer a MySql-specific DataTable (and maybe a DataSet and DataRow, too). Why?
You (or at least I) often do someting like this:

	MySql.Data.MySqlClient.MySqlDataAdapter da = new MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM table1", "some connection string");
	System.Data.DataTable dt = new DataTable();
	da.Fill(dt);
	dataGridView1.DataSource = dt;

This could be more easy and shorter by something like that:

	MySql.Data.MySqlClient.MySqlDataTable myDt = new MySql.Data.MySqlClient.MySqlDataTable("SELECT * FROM table1", "some connection string");
	myDt.Fill();
	dataGridView1.DataSource = myDt;

So there should be a class called MySqlDataTable in MySqlClient-namespace which derives from System.Data.DataTable an has his own MySqlConnection and MySqlDataAdapter within.
Not only that this notation is simpler an clearer, it also has some additional advantages:

	1. You could handly MySql-specific issues with ZeroDateTime better by overloading the access-methods to the fields for date/time-types
	2. You could implement something like paging (must be able to switch on/off, maybe as a parameter to the Fill()-Method
	   In the example code above, if the select statement returns a large number of records the program execution would block until the complete DataTable is returned by the server which could take some long time. No good expirience to the end-user. :-(
	   In a MySqlDataTable handling its own DataAdapter, there could be some automatic paging, meaning that only that many records are retreived which are accessed at one time.
	   With the example above, binding to a GridControl, the grid only requests that many records from the DataTable which it currently displays. It additionaly requests the total number of records to calculate the size of the scroll bar.
	   One idea would be to automaticaly add some 'LIMIT x, y' to the statement for requesting pages, the other one would be to call the Fill()-method of the DataAdapter within for only some parts of the result. Second one is not that good, because the server still sends everythin and the connection is kept open, so I would prefer to first call something like 'COUNT(*)' and then make pages with 'LIMIT x,y'
	3. You could implement some automatic background-requesting, meaning that in the example above the Fill()-Method could create a seperate task which executes the request, so the gridControl already shows the first few records, while in background the remainign ones are retreived.

I know that implementing that would be a lot of work, but I think it could be worth the work..
I'm looking forward to hear your opinion about that idea.

How to repeat:
see example above

Suggested fix:
see above