Description:
Visual Studio 2005 introduces a new methodology for interacting with data sources, called DDEX. In concert with Active Data Objects 2.0, this system makes it easier for developers to access data sources from within their programs or ASP.NET Web applications.
At present, the MySQL Connector does not register with DDEX, and does not extend the required base classes to be used as a DDEX provider. It does not display in the list of providers when using the Select/Change Data Source dialog, when shoved in using a registry patch it does not provide any UI for changing connection string parameters and instead falls back to a PropertyGrid with "ConnectionString" as the only property, one cannot drag an instance from the Server/Data/Database Connections window onto a DataSet design surface because it does not appear in Server Connections, and, as reported by Emanuele Scozzafava in bug 16126, attempting to use it as a data provider by hand fails.
(This is essentially bugs 16126 and 17182, only much broader.)
How to repeat:
a. Does not display in Select/Change Data Source:
1. Open Visual Studio 2005, or a Visual * 2005 Express Edition, and display the Server Connections, Data Connections, or Database Connections window by selecting it from the View menu or pressing Ctrl-Alt-S. (The window name varies by Visual Studio edition.)
2. In the Connections window, click the "Connect To Database" button, or right-click inside the treeview and select "Add Connection...". If a dialog titled "Add Connection" appears (if, for example, you have used the Connector/ODBC in the past) select the "Change..." button.
In the "Select/Change Data Source" window, under data sources, there is no MySQL DB source listed.
3. Select "<other>" from the list of data sources and open the combo box labeled "Data provider:"
There is no ".NET Framework Data Provider for MySQL" listed.
b. Does not appear in Server Explorer, cannot drag from Server Explorer onto DataSet design surface:
Essentially, the same as a.
c. When registered as a provider, does not display UI:
1. Add the following patch to the registry:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\DataProviders\{7F6C196E-32BC-46c7-AF24-37C66ACDECFB}]
@=".NET Framework Data Provider for MySQL"
"Technology"="{77AB9A9D-78B9-4ba7-91AC-873F5338F1D2}"
"InvariantName"="MySQL.Data.MySQLClient"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\DataProviders\{7F6C196E-32BC-46c7-AF24-37C66ACDECFB}\SupportedObjects]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\DataProviders\{7F6C196E-32BC-46c7-AF24-37C66ACDECFB}\SupportedObjects\DataConnectionProperties]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\DataProviders\{7F6C196E-32BC-46c7-AF24-37C66ACDECFB}\SupportedObjects\DataConnectionSupport]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\DataProviders\{7F6C196E-32BC-46c7-AF24-37C66ACDECFB}\SupportedObjects\DataObjectSupport]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\DataProviders\{7F6C196E-32BC-46c7-AF24-37C66ACDECFB}\SupportedObjects\DataSourceSpecializer]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\DataProviders\{7F6C196E-32BC-46c7-AF24-37C66ACDECFB}\SupportedObjects\DataTransactionSupport]
2. Repeat the steps for a., above. You will notice that a ".NET Framework Data Provider for MySQL" has appeared in the list of data providers. Select it and select "OK". An "Add Connection" dialog will appear.
The "Add Connection" dialog will contain a property grid, with one property, named "ConnectionString", listed.
d. Provider cannot be used even by hand.
Repeat the steps for c., optionally enter a connection string, and click OK. You will be informed via dialog that .NET is "Unable to find the requested .Net Framework Data Provider. It may not be installed."
-or-
Copy this code within the body of a asp.net 2.0 page:
<asp:SqlDataSource ID="SqlDataSource1"
runat="server"
ConnectionString="Data Source=100.100.100.46;User ID=root"
ProviderName="MySql.Data.MySqlClient"
SelectCommand="SELECT * FROM mysql">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
You wil be informed of the same error.
Suggested fix:
1. Change MySql.Data.MySqlClient so that either the assembly name is MySql.Data.MySqlClient or the database provider classes are members of the MySql.Data namespace.
2. Adjust the inheritance of the relevant classes:
MySqlConnection must inherit from System.Data.Common.DbConnection.
MySqlConnectionString must be public and inherit from System.Data.Common.DbConnectionStringBuilder. Additionally, it should use the DbConnectionStringBuilder as a backing store rather than MySql.Data.Common.DBConnectionString.
MySqlCommand must inherit from System.Data.Common.DbCommand.
MySqlDataAdapter already inherits from System.Data.Common.DataAdapter.
MySqlTransaction must inherit from System.Data.Common.DbTransaction.
MySqlDataReader should inherit from System.Data.Common.DbDataReader.
MySqlParameter should inherit from System.Data.Common.DbParameter.
3. Create a MySqlProviderFactory that inherits from System.Data.Common.DbProviderFactory.
4. Create a VSDataObjectSupport and a VSDataViewSupport XML file to provide Visual Studio with information on how to display and otherwise deal with MySQL tables in Server Explorer
5. Have the installer register the MySQL provider with the .NET Framework under the DbProviderFactories section of the system.data section of the machine configuration file.
6. Have the installer register the MySQL provider with Visual Studio .NET using the registry patch listed above in How to repeat section c.
7. Optionally, implement a user control that inherits from Microsoft.VisualStudio.Data.DataConnectionUIControl. If you do not, then Visual Studio will just display a property grid with the properties from a MySqlConnectionString object.