- Posted by reggie on May 12, 2008
Hi,
MySQL Connector/Net 5.1.6 a new version of the all-managed .NET driver for MySQL has been released. This is a minor release involving mainly bug fixes.
Version 5.1.6 works with all versions of MySQL including MySQL-4.1, MySQL-5.0, MySQL-5.1 beta or the MySQL-6.0 Falcon "Preview".
It is now available in source and binary form from [http://dev.mysql.com/downloads/connector/net/5.1.html] and mirror sites (note that not all mirror sites may be up to date at this point of time - if you can't find this version on some mirror, please try again later or choose another download site.)
Bugs fixed
- Fixed problem where parameters lists were not showing when you tried to alter a routine in server explorer. (bug #34359)
- Fixed a problem in procedure cache where it was possible to get into a race condition and cause a memory leak (bug #34338)
- Fixed problem where attempting to use an isolation level other than the default with a transaction scope would use the default instead (bug #34448)
- Fixed problem that causes the TableAdapter wizard to only generate insert statements. The problem was that our code to retrieve index columns was broken. (bug #31338)
- Fixed problem with connections staying open after being used with SqlDataSource. The problem was that we were not returning an enumerator for our reader with the closeReader option set to true when we were supposed to. (Bug #34460)
- Fixed problem where the bit data type would continue to return null values once it saw a null value in a previous row (bug #36313)
- Fixed problem with MembershipUser.GetPassword where attempting to retrieve a password on a user where password Q&A is not required would throw an exception (bug #36159)
- Fixed a problem with MembershipUser.GetNumberOfUsersOnline. It actually works now :) (bug #36157)
- Fixed documentation that still stated that setting port to -1 was necessary for a named pipe connection (bug #35356)
- Fixed data type processing so that geometry fields are returned as binary. (bug #36081)
- Fixed problem that kept our provider from showing up in the provider list when configuring a new connection from a SqlDataSource
- Fixed problem where setting the ConnectionString property of MySqlConnection to null would throw an exception (bug #35619)
Enjoy and thanks for the support!
- Posted by reggie on April 17, 2008
MySQL Connector/Net 5.0.9, a new version of the all-managed .NET driver for MySQL has been released. This release is an update to the existing production-quality 5.0 series.
We plan for this to be the last release in the 5.0 series. We will only be updating the 5.0 product in the event a "data-loss" type bug is discovered. We encourage all new products to use the new 5.1 product.
Version 5.0.9 works with all versions of MySQL including MySQL-4.1, MySQL-5.0, MySQL-5.1 beta or the MySQL-6.0 Alpha.
It is now available in source and binary form from here and mirror sites (note that not all mirror sites may be up to date at this point of time - if you can't find this version on some mirror, please try again later or choose another download site.)
Features or behavior changes
- added implementation of MySqlCommandBuilder methods QuoteIdentifier and UnquoteIdentifier (bug #35492)
Bugs fixed
Fixed problem where fields that were blobs but did not include the BLOB flag were treated as binary when they should have been treated as text. (Bug #30233)
Changed from using Array.Copy to Buffer.BlockCopy in MySqlDataReader.GetBytes. This helps with memory usage as we expect the source and destination arrays to not be overlapping. (Bug #31090) Fixed problem that prevented commands from being executed from the state change handler. Not sure why you would want to do this but... (bug #30964) Fixed issue where column name metadata was not using the charset given on the connection string (Bug #31185) Fixed problem with installer where the installation might report a failure to remove the performance counters if the performance counter category had already been removed for some reason Fixed problem with installer where attempting to install over a failed uninstall could leave multiple clients registered in machine.config. (Bug #31731) Fixed problem with connection string caching where our collection class was using case insensitive semantics and this causes cases where a user originally used the wrong case for a user id and then fixed it to still get access denied errors. (Bug #31433) improved the speed of load data local infile significantly fixed MySqlDateTime.ToString() to properly return the date value (Bug #32010) fixed problem where string parameters who have their size set after their value could cause exceptions (Bug #32094) fixed problem where old code was preventing creating parameter objects with non-input direction using just a constructor (Bug #32093) fixed problem where a syntax error in a set of batch statements could leave the data adapter in a state that appears hung (bug #31930) fixed the MySqlException class to set the server error code in the Data[] hash so that DbProviderFactory users can access the server error code (Bug #27436) fixed problem where changing the connection string of a connection to one that changes the parameter marker after the connection had been assigned to a command but before the connection is opened can cause parameters to not be found (bug #13991) some fixes to cancel and timeout operations so that they are more dependable fixed problem where cloning a parameter that has not yet had its type set would yield a cloned parameter that would no longer infer it's type from the value set
- Posted by reggie on April 14, 2008
I was so looking forward to hanging out in Santa Clara this week with all the fine people that come to see my .NET and Windows presentations (yes, both of you!) at the annual MySQL Users Conference. The problem is that I hurt my knee Saturday evening and now I can barely walk. So I decided it was better for me to stay home and try to stay off the knee as much as I can. Sorry for those people who were planning on attending my building and debugging on Windows session however the entity framework session should still happen with the ever-capable David Sceppa at the helm.
So go have fun while I sit here and wince. :(
- Posted by reggie on April 8, 2008
Recently I've read lots of forum posts from frustrated users claiming that their is something wrong with the Connector/Net installer. They reference the connector in their web app, then deploy the app to their remote host only to find that the app no longer works. I'll walk through a simple web app sample and show where the confusion comes from and what they should be doing instead. This sample assumes you have a recent build of Connector/Net installed with Visual Studio integration enabled.
First, we'll create a web app using Visual Studio 2008.
The next thing that many developers do is create some type of page that references the connector. Often this is a SqlDataSource that they will be connecting to a datagrid. To do that you drop a SqlDataSource control and a GridView control on the page. After setting the grid view to use the sql data source you now need to configure the data source control. Normally to do that you would select 'Configure Data Source...' from the smart tasks popup and walk through adding a data connection to your app (as well as Server Explorer). Due to a bug in our implementation currently you need to add the connection to Server Explorer first and then pick that connection in the Configure Data Source dialog. Once done with this you can find the new connection string in your web.config and see how the data source control is tied to it. Here is the connection string added to my web.config.
<connectionStrings>
<add name="testConnectionString"
connectionString="server=localhost;user id=root;database=test"
providerName="MySql.Data.MySqlClient" />
</connectionStrings>
Here is how my SqlDataSource is configured now.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
ProviderName="<%$ ConnectionStrings:testConnectionString.ProviderName %>"
SelectCommand="select * from t1"></asp:SqlDataSource>
At this point you can hit F5 in VS and the web app will run and show you the data you specified in your query. However, if you deploy this application to a remote server that does not have Connector/Net installed then it will fail and you may see something like this:
What's going on? The first thing to understand is how the SqlDataSource connects to a data provider. If you refer back to our connection string you'll see the attribute providerName have the value 'MySql.Data.MySqlClient'. That is the invariant name of Connector/Net. However this name is not enough to locate the right assembly to load. This mapping is done in either the machine.config or web.config files. The Connector/Net installer makes the proper registrations in the machine.config file. Here is the DbProviderFactories section from my machine.config (I've omitted all entries but Connector/Net for brevity).
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,
Version=5.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
With this entry in machine.config then the system can match the invariant name to a fully qualified assembly name and also identify the client factory class that should be used. You can see that by examining the type attribute above.
So what do you do if you are deploying this app to a remote server that you can't install Connector/Net on? Simple. Add this registration to your web.config. Just drop it in right outside the system.web block like this:
<system.data>
<DbProviderFactories>
<clear/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,
Version=5.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
So why the <clear/> tag? You can't doubly add provider factories to the config system so if you have Connector/Net installed on your dev system and you register the provider factory in your web.config then you will be doubly adding them. The clear tag clears out all the provider factories pulled in from machine.config and then adds in yours. Now if you are mixing providers then you'll need to adjust this to your situation.
I hope this blog post has cleared up some of the reasons why people have working web apps on their dev systems but then are confused when it doesn't work after deploy.
- Posted by reggie on March 14, 2008
When we last left our hero he had just got the global data menu working under '05 and '08. Next step was use of the table browser. Here's a shot of it working with SQL Server data. Now there is no particular reason to use this data browser instead of writing our own other than it's just less work and it has a nice look and feel.
On the surface this looks pretty easy. After a little digging I discovered that this command binding will add a "Show Table Data" menu option and bring up a nice OleDB-based data browser under VS 2005.
<CommandBinding name="Browse_Data" guid="501822E1-B5AF-11d0-B4DC-00A0C91506EF" cmdid="12384"
handler="Microsoft.VisualStudio.DataTools.DBPackage.VDT_OLEDB_CommandHandler_TableTools">
<Parameter value="Open"/>
</CommandBinding>
The problem, of course, is that this doesn't work under VS 2008. The handler under VS 2008 is implemented by an object with the guid of 884DD964-5327-461f-9F06-6484DD540F8F. My first approach was to define two of these bindings and no matter which version of VS ran one of them would fail (and not add any menu item) while the other would succeed. VS doesn't like that. Apparently the guid and cmdId together form a key and you get a key added twice error. Hmmm
My good buddy Stephen at Microsoft offered up the solution of overriding the GetDataViews method of DataViewSupport and tweaking the XML that is returned. It turns out that he was spot on. I set all the handlers in the XML file to be proper for VS 2005, changed my DataViewSupport derived class to now use the no parameter constructor base, and then overrode the GetDataViews method like so.
public override Stream GetDataViews()
{
string xmlName = "MySql.Data.VisualStudio.DDEX.MySqlDataViewSupport.xml";
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Stream stream = executingAssembly.GetManifestResourceStream(xmlName);
StreamReader reader = new StreamReader(stream);
string xml = reader.ReadToEnd();
reader.Close();
// if we are running under VS 2008 then we need to switch out a couple
// of command handlers
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;
if (dte.Version.StartsWith("9"))
xml = xml.Replace
("Microsoft.VisualStudio.DataTools.DBPackage.VDT_OLEDB_CommandHandler_TableTools",
"884DD964-5327-461f-9F06-6484DD540F8F");
MemoryStream ms = new MemoryStream(xml.Length);
StreamWriter writer = new StreamWriter(ms);
writer.Write(xml);
writer.Flush();
ms.Position = 0;
return ms;
}
I won't bother with showing you a pic of it working in MySQL because it looks just like the other pic. But, then again, that's the point. :)
- Posted by reggie on March 14, 2008
It's no secret that that SQL Server integrates better into Visual Studio than any other database. We are trying to change that. Two of the things that I wanted to implement in the new version of our integration code is to replicate the Add New submenu and use the the built-in table browsers that Sql Server uses. Here is a screen shot of the global data menu we wanted to reproduce.

This menu should also work in Visual Studio 2005 though the top four items (Schema Compare, Data Compare, Refactor, and T-SQL Editor) won't be there. The problem is that adding items to the global data menu is not directly supported in Visual Studio 2005 but it is supported in 2008. This is further complicated due to the fact that Microsoft moved from using CTC files to VSCT files to define package resources. I didn't want to ship two binaries (one for 2005 and one for 2008) so I have continued to use the CTC format. Here is what I had to do to get it working.
First, I defined a constant for the appropriate menu group in VS 2005. I put this in my file named guids.h
#define guidVS2005Data { 0x501822e5, 0xb5af, 0x11d0, { 0xb4, 0xdc, 0x00, 0xa0, 0xc9, 0x15, 0x06, 0xef } }
Then I defined two menus and two groups (one for 2005 and one for 2008).
MENUS_BEGIN
guidMySqlProviderCmdSet:menuAddNew2005, guidVS2005Data:8706, 0x1000,, "MySQLAdd", "&Add New";
guidMySqlProviderCmdSet:menuAddNew2008, guidVSData:IDG_DV_GLOBAL1, 0x1000,, "MySQLAdd", "&Add New";
MENUS_END
NEWGROUPS_BEGIN
guidMySqlProviderCmdSet:groupAddNew2005, guidMySqlProviderCmdSet:menuAddNew2005, 0x0000;
guidMySqlProviderCmdSet:groupAddNew2008, guidMySqlProviderCmdSet:menuAddNew2008, 0x0000;
NEWGROUPS_END
Note here that 8706 is the id of the global data menu in VS 2005 and IDG_DV_GLOBAL1 is the id under VS 2008. menuAddNew2005, menuAddNew2008, groupAddNew2005, and groupAddNew2008 are just simple ids I assigned. The reason you need to define the menu twice is because no matter which version of VS you use it will balk at adding the same menu to two different top level groups.
Then I define the commands I want to appear on the menus but I don't put them on the menus here since I need to put them on two different menus.
/* global data menu items */
guidMySqlProviderCmdSet:cmdidAddNewTableGlobal, Group_Undefined:0, 0x0000, OI_NOID, BUTTON, DIS_DEF, "&Table";
guidMySqlProviderCmdSet:cmdidAddNewViewGlobal, Group_Undefined:0, 0x0001, OI_NOID, BUTTON, DIS_DEF, "Vie&w";
guidMySqlProviderCmdSet:cmdidAddNewProcedureGlobal, Group_Undefined:0, 0x0002, OI_NOID, BUTTON, DIS_DEF, "Stored &Procedure";
guidMySqlProviderCmdSet:cmdidAddNewFunctionGlobal, Group_Undefined:0, 0x0003, OI_NOID, BUTTON, DIS_DEF, "Stored &Function";
guidMySqlProviderCmdSet:cmdidAddNewUDFGlobal, Group_Undefined:0, 0x0004, OI_NOID, BUTTON, DIS_DEF, "&UDF";
Now I add the commands to both menus
guidMySqlProviderCmdSet:cmdidAddNewTableGlobal, guidMySqlProviderCmdSet:groupAddNew2005, 1;
guidMySqlProviderCmdSet:cmdidAddNewTableGlobal, guidMySqlProviderCmdSet:groupAddNew2008, 1;
/* others omitted for brevity */
Now we need to add our commands to our data view XML file. Here is what one command binding looks like.
<CommandBinding name="AddNewTable" guid="B87CB51F-8A01-4c5e-BF3E-5D0565D5397D"
cmdid="500" handler="MySql.Data.VisualStudio.MySqlDataViewCommandHandler">
<Parameter value="HighLevel"/>
</CommandBinding>
Notice the command parameter named "HighLevel". This is important because without it the menus will not function correctly in VS 2005. You also need to add all the commands into the command bindings of every node. Yes, this is very repetitious but is necessary due to a bug in VS 2005. Without doing that the menu will appear when the connection node is selected but will disappear when on the other nodes.
I would also like to thank a developer at Microsoft who answered tons of my questions and helped me sort this out. His name is Stephen Provine and I really appreciate all his hard work. With all this done, here is the same shot working with MySQL.

- Posted by reggie on March 4, 2008
I've been working very hard on adding new features to our Visual Studio integration and one of those features is syntax highlighting of SQL when creating and editing stored procedures. With this new build we are using the core editor that is built inside Visual Studio. This brings other features such as the ability to split the code window. Currently I am hoping to have these new features in our 5.3 product.

- Posted by reggie on February 26, 2008
MySQL Connector/Net 5.2.1, a new version of the all-managed .NET driver for MySQL has been released. This release is an alpha and may contain bugs with some of them possibly being severe. You are strongly urged to not use this release in production environments. This release is intended only for testing and feedback purposes.
IMPORTANT
This is a refresh of the 5.2.0 alpha release. Please consult the 5.2.0 change log for a complete list of changes and bug fixes in that release.
Version 5.2.1 works with all versions of MySQL including MySQL-4.1, MySQL-5.0, MySQL-5.1 beta or the MySQL-6.0 Falcon "Preview".
It is now available in source and binary form from [http://dev.mysql.com/downloads/connector/net/5.2.html] and mirror sites (note that not all mirror sites may be up to date at this point of time - if you can't find this version on some mirror, please try again later or choose another download site.)
Features or behavior changes
No behavior changes in this release.
Bugs fixed
- Tons of fixes in providers. The actually work now. :)
- Fixed new parameter handling code so that procedures and functions now work (bug #34699)
- Fixed problem with Visual Studio 2008 integration that caused popup menus on server explorer nodes to not function
- Fixed web providers so that they don't attempt to check their schema or cache their application id if the connection string has not been set. (bug #34451)
- Fixed installer that did not install the DDEX provider binary if the Visual Studio 2005 component was not selected. (bug #34674)
- Fixed password validation logic for creating users and changing passwords. It actually works now. (bug #34792)
Enjoy and thanks for the support!
- Posted by reggie on February 25, 2008
There are few things that make as little sense as the help technologies under Windows and especially the help collections that are required to integrate into Visual Studio. In typical Microsoft fashion, the help topics and samples related to building a help collection don't provide any guidance on more advanced scenarios like registering a help collection with both Visual Studio 2005 and Visual Studio 2008 from a single installer.
It's even more fun when the MSI based installer fails to do what it is supposed to do and lets you know that it failed only it provides no other information.
It's times like these I think MS intentionally develops products the way they do just to create a third party market to fix their mistakes. ;)
One such "fix" is the Helpware guys and their wonderful line of products. I would specifically like to call out their H2REG product that takes a simple .ini file listing the files in your help collection and registers it with Windows. It can also perform a namespace merge before exiting.
Normally they ask a small fee to distribute h2reg with your product commercially but Rob was kind enough to grant MySQL a license to distribute h2reg with our open source products. His products are great and it's great to see his willingness to help out the open source community.
Rob, thank you!
- Posted by reggie on February 11, 2008
Hi,
MySQL Connector/Net 5.2.0 a new version of the all-managed .NET driver for MySQL has been released. This release is an alpha and may contain bugs with some of them possibly being severe. You are strongly urged to not use this release in production environments. This release is intended only for testing and feedback purposes.
There are many changes in this release including an extensive change related to using @ as a parameter marker instead of ?. There is a more thorough write-up of the breaking changes in the release notes and we strongly encourage you to read those notes to better understand the changes.
Version 5.2.0 works with all versions of MySQL including MySQL-4.1, MySQL-5.0, MySQL-5.1 beta or the MySQL-6.0 Falcon "Preview".
It is now available in source and binary form from [http://dev.mysql.com/downloads/connector/net/5.2.html] and mirror sites (note that not all mirror sites may be up to date at this point of time - if you can't find this version on some mirror, please try again later or choose another download site.)
Features or behavior changes
- Added connection string option 'Treat Tiny As Boolean' so applications that expect TINYINT(1) to return an integer will not break (bug #34052). This setting is true by default. If your application expects TINYINT(1) columns to be returned as integer, you need to set this setting to false.
- Added the ability to clear a single or all connection pools.
- Added Visual Studio 2008 integration.
- Added support for batching to MySqlDataAdapter. Batching is fully supported including collapsing inserts down into the multi-value form if possible.
- Added MySqlScript class for executing scripts against a database.
- Marked connection string option 'Use Old Syntax' as obsolete and changed code to allow both @ and ? as parameter markers.
- Added MySqlBulkLoader class for easily executing LOAD DATA commands
- Added support for treating BINARY(16) columns as GUID values
- Perfmon counters are now created using Wix code instead of a managed custom action. This seems to help the problem where some installation were failing becausing of being unable to register the counters.
- Added Allow User Variables connection string option so that users can use user variables without getting missing parameter exceptions. This feature is related to our move back to using @ as parameter marker. (see release notes)
- Added a new profile provider to our web providers collection
- Completely revamped provider schema allowing for tighter integration between the providers
Bugs fixed
- Fixed problem with membership provider where FindUserByEmail would fail trying to add a second parameter with the same name as the first (bug #33347)
- Fixed long standing problem with compression over a network. It's now fast again. (bug #27865)
- Fixed nant compilation problem on mono (bug #33508)
- Fixed problem where connection state reported through the state change handler was not showing Open (bug #34082)
- Incorporated some connection string cache optimizations sent to us by Maxim Mass (bug #34000)
- Fixed problem with opening a connection that was previously closed by sudden server disconnection (bug #33909)
- Fixed code to yield better exception when using different connection strings in a single transaction (bug #34204)
- Small bug fix and speed enhancement in Statement.TokenizeSql (bug #34220)
Enjoy and thanks for the support!
Reggie