Modified:
branches/5.0/CHANGES
branches/5.0/Driver/Source/command.cs
branches/5.0/Driver/Source/parameter_collection.cs
branches/5.0/TestSuite/Source/ParameterTests.cs
Log:
- 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)
Modified: branches/5.0/CHANGES
===================================================================
--- branches/5.0/CHANGES 2007-11-06 16:09:09 UTC (rev 1076)
+++ branches/5.0/CHANGES 2007-11-06 16:15:09 UTC (rev 1077)
@@ -28,8 +28,10 @@
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)
-
Version 5.0.8 8/16/2007
Bug #28706 Log messages are truncated
Modified: branches/5.0/Driver/Source/command.cs
===================================================================
--- branches/5.0/Driver/Source/command.cs 2007-11-06 16:09:09 UTC (rev 1076)
+++ branches/5.0/Driver/Source/command.cs 2007-11-06 16:15:09 UTC (rev 1077)
@@ -57,7 +57,7 @@
{
designTimeVisible = true;
cmdType = CommandType.Text;
- parameters = new MySqlParameterCollection();
+ parameters = new MySqlParameterCollection(this);
updatedRowSource = UpdateRowSource.Both;
cursorPageSize = 0;
cmdText = String.Empty;
@@ -78,8 +78,6 @@
: this(cmdText)
{
Connection = connection;
- if (connection != null)
- parameters.ParameterMarker = connection.ParameterMarker;
}
/// <include file='docs/mysqlcommand.xml' path='docs/ctor4/*'/>
@@ -180,8 +178,6 @@
Transaction = null;
connection = (MySqlConnection)value;
- if (connection != null)
- parameters.ParameterMarker = connection.ParameterMarker;
}
}
Modified: branches/5.0/Driver/Source/parameter_collection.cs
===================================================================
--- branches/5.0/Driver/Source/parameter_collection.cs 2007-11-06 16:09:09 UTC (rev 1076)
+++ branches/5.0/Driver/Source/parameter_collection.cs 2007-11-06 16:15:09 UTC (rev 1077)
@@ -38,9 +38,9 @@
{
private ArrayList items = new ArrayList();
private Hashtable indexHash;
- private char paramMarker = '?';
+ private MySqlCommand owningCommand;
- internal MySqlParameterCollection()
+ internal MySqlParameterCollection(MySqlCommand cmd)
{
#if NET20
indexHash = new Hashtable(StringComparer.CurrentCultureIgnoreCase);
@@ -49,12 +49,12 @@
new CaseInsensitiveComparer());
#endif
Clear();
+ owningCommand = cmd;
}
internal char ParameterMarker
{
- get { return paramMarker; }
- set { paramMarker = value; }
+ get { return owningCommand.Connection.ParameterMarker; }
}
#region Public Methods
@@ -415,7 +415,7 @@
if (indexHash.ContainsKey(inComingName))
throw new MySqlException(
String.Format(Resources.ParameterAlreadyDefined, value.ParameterName));
- if (inComingName[0] == paramMarker)
+ if (inComingName[0] == ParameterMarker)
inComingName = inComingName.Substring(1, inComingName.Length - 1);
if (indexHash.ContainsKey(inComingName))
throw new MySqlException(
Modified: branches/5.0/TestSuite/Source/ParameterTests.cs
===================================================================
--- branches/5.0/TestSuite/Source/ParameterTests.cs 2007-11-06 16:09:09 UTC (rev 1076)
+++ branches/5.0/TestSuite/Source/ParameterTests.cs 2007-11-06 16:15:09 UTC (rev 1077)
@@ -562,5 +562,21 @@
ParameterDirection.Output, true, 0, 0, "id", DataRowVersion.Current, 0);
Assert.AreEqual(ParameterDirection.Output, p1.Direction);
}
- }
+
+ /// <summary>
+ /// Bug #13991 oldsyntax configuration and ParameterMarker value bug
+ /// </summary>
+ [Test]
+ public void SetOldSyntaxAfterCommandCreation()
+ {
+ string connStr = this.GetConnectionString(true);
+ MySqlConnection c = new MySqlConnection(connStr);
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id) VALUES (@id)", c);
+ c.ConnectionString = connStr += ";old syntax=yes";
+ cmd.Parameters.AddWithValue("@id", 2);
+ c.Open();
+ cmd.ExecuteNonQuery();
+ c.Close();
+ }
+ }
}
Thread |
---|
• Connector/NET commit: r1077 - in branches/5.0: . Driver/Source TestSuite/Source | rburnett | 6 Nov |