diff --git a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog index 675a72a5c37cbe9092289d19698dd57917df19f4..c43bf957255ea648a598d76cf6ef562e3a39c7f5 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog +++ b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog @@ -1,3 +1,9 @@ +2010-10-01 Veerapuram Varadhan + + ** Fixes #561667 + * SqlCommand.cs (Dispose): While Disposing, set connection's datareader + to null so as the connection can be reused with another datareader. + 2010-07-28 Veerapuram Varadhan ** Fixes #584833 diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs index e9cf8c112feade26834933789c299425955c3462..b0962359876ee29436e75ccbf9974bb4459915db 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs @@ -706,6 +706,8 @@ namespace System.Data.SqlClient { if (disposed) return; if (disposing) { parameters.Clear(); + if (Connection != null) + Connection.DataReader = null; } base.Dispose (disposing); disposed = true; diff --git a/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog b/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog index b3c7fd0ab337ef5e541ba5dc7699c7f1bbecf69d..8f8e70007904602982bd894374507922f90ee879 100644 --- a/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog +++ b/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog @@ -1,3 +1,7 @@ +2010-10-01 Veerapuram Varadhan + + * SqlCommandTest.cs: Add test for bug#561667 + 2010-09-20 Veerapuram Varadhan * SqlDataReaderTest.cs: Add test for bug#613087 diff --git a/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs b/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs index 7274ddfd5889333655efd807f575c5e15d667d5c..50ad553ebe93b2cc170bd19c33e73b71f7229a58 100644 --- a/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs +++ b/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs @@ -3019,6 +3019,37 @@ namespace MonoTests.System.Data.SqlClient } } + [Test] // bug#561667 + public void CmdDispose_DataReaderReset () + { + try { + conn = (SqlConnection) ConnectionManager.Singleton.Connection; + ConnectionManager.Singleton.OpenConnection (); + string query1 = "SELECT fname FROM employee where lname='kumar'"; + string query2 = "SELECT type_int FROM numeric_family where type_bit = 1"; + DataTable t = null; + + t = GetColumns(conn, query1); + Assert.AreEqual ("suresh", t.Rows[0][0], "CmdDD#1: Query1 result mismatch"); + t = GetColumns(conn, query2); + Assert.AreEqual (int.MaxValue, t.Rows[0][0], "CmdDD#2: Query2 result mismatch"); + } finally { + ConnectionManager.Singleton.CloseConnection (); + conn = null; + } + } + + private DataTable GetColumns(DbConnection connection, string query) + { + DataTable t = new DataTable("Columns"); + using (DbCommand c = connection.CreateCommand()) + { + c.CommandText = query; + t.Load(c.ExecuteReader()); + } + return t; + } + // used as workaround for bugs in NUnit 2.2.0 static void AreEqual (object x, object y, string msg) {