Modified:
branches/5.1/CHANGES
branches/5.1/Driver/Source/command.cs
branches/5.1/Driver/Source/parameter_collection.cs
branches/5.1/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.1/CHANGES
===================================================================
--- branches/5.1/CHANGES 2007-11-06 16:15:09 UTC (rev 1077)
+++ branches/5.1/CHANGES 2007-11-06 16:20:12 UTC (rev 1078)
@@ -106,6 +106,9 @@
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.1/Driver/Source/command.cs
===================================================================
--- branches/5.1/Driver/Source/command.cs 2007-11-06 16:15:09 UTC (rev 1077)
+++ branches/5.1/Driver/Source/command.cs 2007-11-06 16:20:12 UTC (rev 1078)
@@ -63,7 +63,7 @@
designTimeVisible = true;
cmdType = CommandType.Text;
parameterMap = new ArrayList();
- parameters = new MySqlParameterCollection();
+ parameters = new MySqlParameterCollection(this);
updatedRowSource = UpdateRowSource.Both;
cursorPageSize = 0;
cmdText = String.Empty;
@@ -84,8 +84,6 @@
: this(cmdText)
{
Connection = connection;
- if (connection != null)
- parameters.ParameterMarker = connection.ParameterMarker;
}
/// <include file='docs/mysqlcommand.xml' path='docs/ctor4/*'/>
@@ -186,8 +184,6 @@
this.Transaction = null;
connection = (MySqlConnection)value;
- if (connection != null)
- parameters.ParameterMarker = connection.ParameterMarker;
}
}
Modified: branches/5.1/Driver/Source/parameter_collection.cs
===================================================================
--- branches/5.1/Driver/Source/parameter_collection.cs 2007-11-06 16:15:09 UTC (rev 1077)
+++ branches/5.1/Driver/Source/parameter_collection.cs 2007-11-06 16:20:12 UTC (rev 1078)
@@ -37,9 +37,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);
@@ -48,12 +48,12 @@
new CaseInsensitiveComparer());
#endif
Clear();
+ owningCommand = cmd;
}
internal char ParameterMarker
{
- get { return paramMarker; }
- set { paramMarker = value; }
+ get { return owningCommand.Connection.ParameterMarker; }
}
#region Public Methods
@@ -414,7 +414,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.1/TestSuite/Source/ParameterTests.cs
===================================================================
--- branches/5.1/TestSuite/Source/ParameterTests.cs 2007-11-06 16:15:09 UTC (rev 1077)
+++ branches/5.1/TestSuite/Source/ParameterTests.cs 2007-11-06 16:20:12 UTC (rev 1078)
@@ -568,5 +568,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: r1078 - in branches/5.1: . Driver/Source TestSuite/Source | rburnett | 6 Nov |