Bug #75322 Connector/Net Connect_Attrs - documented feature non functional
Submitted: 28 Dec 2014 17:56 Modified: 2 Nov 2015 21:00
Reporter: Chris Herridge Email Updates:
Status: Not a Bug Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: Connect_Attrs, connection string, Connector/Net

[28 Dec 2014 17:56] Chris Herridge
Hi, I'd like to specify custom attributes in my Connection Attributes, which will be very useful for Performance Scheme related diagnostics etc. 
I notice on the documentation there's mention of "Connect_Attrs", however they seem to be unmentioned anywhere in the code. And attempting to set that settings causes this error 

System.ArgumentException: Keyword not supported. 
Parameter name: connect_attrs 
at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.GetOption(String key) 
at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.set_Item(String keyword, Object value) 
at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value) 
at MySql.Data.MySqlClient.MySqlConnectionStringBuilder..ctor(String connStr)

How to repeat:
Attempt to set some Connection Attributes in the connectionstring.

Suggested fix:
May I recommend these additions (Taken from 6.9.5's latest source) 

MySqlConnectionStringBuilder.cs @ line 190 
+ options.Add(new MySqlConnectionStringOption("connectattrs", "connect_attrs,connection attributes", typeof(string), "", false)); 

MySqlConnectionStringBuilder.cs @ line 791 
+[DisplayName("Connection Attributes")] 
+[Description("A Comma separated <key>:<value> list of extra connection attributes")] 
+public string ConnectionAttributes 
+ get { return (string)values["connectattrs"]; } 
+ set { SetValue("connectattrs", value); } 

NativeDriver.cs @ line 931 
+//Now join in some custom attributes 
+if (owner.Settings.ConnectionAttributes != null) 
+	string[] attributes = owner.Settings.ConnectionAttributes.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries); 
+	string[] attributePair; 
+	foreach (string attributeKeyValue in attributes) { 
+	attributePair = attributeKeyValue.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); 
+	if (attributePair.Length == 2) 
+	{ 
+	connectAttrs += string.Format("{0}{1}", (char)attributePair[0].Length, attributePair[0]); 
+	connectAttrs += string.Format("{0}{1}", (char)attributePair[1].Length, attributePair[1]); 
+	} 
+	} 
[30 Dec 2014 10:03] Chiranjeevi Battula
Hello Chris Herridge,

Thank you for the bug report.
Verified this behavior on Visual Studio 2013 (C#.Net) with  MySQL Connector/Net 6.9.5.

[2 Nov 2015 21:00] Roberto Ezequiel Garcia Ballesteros

Connection attributes are used internally by C/NET. They are not designed to be set in connection string.