[Mono-bugs] [Bug 68973][Blo] New - ExecuteNonQuery() returns wrong RowsAffected

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 1 Nov 2004 08:08:11 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ph_knecht@yahoo.com.

http://bugzilla.ximian.com/show_bug.cgi?id=68973

--- shadow/68973	2004-11-01 08:08:11.000000000 -0500
+++ shadow/68973.tmp.20114	2004-11-01 08:08:11.000000000 -0500
@@ -0,0 +1,98 @@
+Bug#: 68973
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Windows XP
+OS Details: German XP Professional / German locales
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Blocker
+Component: Sys.Data.SqlClient
+AssignedTo: rodrigo@novell.com                            
+ReportedBy: ph_knecht@yahoo.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: ExecuteNonQuery() returns wrong RowsAffected 
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+I'm using latest precompiled dll's from 30.10.2004. 
+
+When using rowsaffected=ExecuteNonQuery() AFTER issuing a select command,
+it returns the rows from the selected command not the really updated ones.
+
+On MS.NET (with SqlClient) it works as exspected.
+
+I'm porting an O/R Mapper (www.npersist.com) to mono and this issue is
+blocking me.
+
+Steps to reproduce the problem:
+
+using System.Data.SqlClient;
+namespace rowsaffectederror
+{
+	class Class1
+	{
+		static void Main(string[] args)
+		{
+			string cstr;
+			string  sql;
+			SqlCommand cmd;
+			SqlConnection cn;
+			SqlDataReader dr;
+			int RowsAffected;
+			int i;
+			int inp;
+			cstr = "Server=127.0.0.1;Database=Northwind;User ID=sa;Password=xyz";
+			
+			// First Step: Execute an Select Command to get multiple records
+			
+			cn = new SqlConnection(cstr);
+			cmd = cn.CreateCommand();
+			cmd.Connection=cn;
+			sql = "Select * from Products where CategoryID = 1";
+            cmd.CommandText = sql;
+			cn.Open();
+			dr = cmd.ExecuteReader();	
+            i=0;
+			while (dr.Read())
+			{
+				i += 1;
+			}
+			cn.Close();
+			dr.Close();
+            Console.WriteLine("We got " + i.ToString() + " Rows from the
+Select Statement");
+			// Second Step: Update ONE record
+			cmd.Connection=cn;
+			sql = "Update Products Set ProductName = 'Yeah' Where ProductID = 24";
+			cmd.CommandText = sql;
+			cn.Open();
+			RowsAffected = cmd.ExecuteNonQuery();	
+			cn.Close();
+			dr.Close();
+            Console.WriteLine("There were " + RowsAffected.ToString() + "
+Rows affected by the update statement");
+			inp=Console.Read();
+		}
+	}
+}
+
+
+Actual Results:
+14
+15
+Expected Results:
+14
+1
+
+How often does this happen? 
+everytime
+
+Additional Information:
+don't hesitate to ask me further questions it wasn't so easy to discover
+this one.