Bug #26041 Connection Protocol Property Error in PropertyGrid Control
Submitted: 2 Feb 2007 16:50 Modified: 20 May 2007 6:17
Reporter: Sean Wright Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.0.3 OS:Microsoft Windows (XP)
Assigned to: CPU Architecture:Any
Tags: propertygrid

[2 Feb 2007 16:50] Sean Wright
When the propertygrid selectedObject property points to a MysqlConnectionStringBuilder object, attempting to change the Connection Protocol property produces the error: "Property value is not valid"

Same problem occurs when attempting to change the Driver Type property.

How to repeat:
Run this code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using MySql.Data.MySqlClient;

namespace stringbuildertest
    public partial class Form1 : Form
        MySqlConnectionStringBuilder csb = new MySqlConnectionStringBuilder();
        public Form1()

        private void Form1_Load(object sender, EventArgs e)
            Configuration machineConfig = ConfigurationManager.OpenMachineConfiguration();
            ConnectionStringsSection csSection = machineConfig.ConnectionStrings;

            for (int i = 0; i < ConfigurationManager.ConnectionStrings.Count; i++)
                ConnectionStringSettings cs = csSection.ConnectionStrings[i];

                if (cs.ProviderName == "Mysql.Data.MySQLClient")
                                    csb.ConnectionString = cs.ConnectionString;
                                    propertyGrid1.SelectedObject = csb;


        private void button1_Click(object sender, EventArgs e)

Suggested fix:

the GetKey routine must be modified by adding two statements:

case "connection protocol":   -> insert after the case "protocol": statement

case "driver type":   -> insert after the case "driver": statement

This eliminates the invalid property error, however now exceptions are thrown in both ConvertToProtocol and ConvertToDriverType routines.  I suspect the error lies in the conversion routines.
[2 Feb 2007 17:26] Sean Wright
Additional change made:

case Keyword.Protocol: ConnectionProtocol = ConvertToProtocol(value); break;

case Keyword.Protocol: ConnectionProtocol = (MySqlConnectionProtocol) value; break;

This works to a certain degree.  No more errors, the property is changed but not displayed in the propertygrid.
[2 Feb 2007 18:13] Sean Wright
I found other properties that threw errors as well.  I have corrected them.  Still have a problem displaying the Driver Type and Connection Protocol in the propertygrid even though the properties are changed.

See attached file for corrections
[2 Feb 2007 18:14] Sean Wright
MySQLConnectionStringBuilder modified code

Attachment: MySqlConnectionStringBuilder.cs (application/octet-stream, text), 27.14 KiB.

[9 Feb 2007 15:51] Sean Wright
Ok, then connector (specifically the MySQLConnectionStringBuilder) will now work properly in a propertygrid control.

Can someone please verify the newly submitted code conforms to project standards?
[9 Feb 2007 15:52] Sean Wright
Final working code on MySQLConnectionStringBuilder, allowing object to be used in a PropertyGrid control

Attachment: MySqlConnectionStringBuilder.cs (application/octet-stream, text), 28.08 KiB.

[7 Apr 2007 18:42] Tonci Grgin
Sean, thanks for your report and patch provided. I will notify c/NET team of it.

Either I have problems with my machine configuration or with your test case (or both :) ) but I'm unable to extract any cs that passes "cs.ProviderName == "Mysql.Data.MySQLClient" " condition but I can see your point in code. So I'll make this report "Verified" and let Reggie decide.

Thanks for your interest in MySQL.
[10 May 2007 21:13] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

[10 May 2007 21:14] Reggie Burnett
Fixed in 5.0.7
[20 May 2007 6:17] MC Brown
A note has been added to the 5.0.7 changelog.