[Mono-bugs] [Bug 78992][Nor] New - SybaseCommand.ExecuteNonQuery returns incorrect number of rows affected.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Aug 1 18:12:26 EDT 2006


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 jonathan.gagnon at croesus.com.

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

--- shadow/78992	2006-08-01 18:12:26.000000000 -0400
+++ shadow/78992.tmp.14929	2006-08-01 18:12:26.000000000 -0400
@@ -0,0 +1,96 @@
+Bug#: 78992
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: tsenganal at novell.com                            
+ReportedBy: jonathan.gagnon at croesus.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: SybaseCommand.ExecuteNonQuery returns incorrect number of rows affected.
+
+Description of Problem:
+
+When inserting a row with SybaseCommand.ExecuteNonQuery and using 
+parameters, this method 
+always returns the number of rows affected plus the number of parameters.
+
+Steps to reproduce the problem:
+
+The code sample is similar to bug #76280 but with the use of parameters :
+
+IDbConnection dbConnection = new SybaseConnection(connectionString);
+dbConnection.Open();
+
+IDbCommand command = dbConnection.CreateCommand();
+command.CommandText = "CREATE TABLE XXX (X INTEGER, Y INTEGER)";
+int rowCount = command.ExecuteNonQuery();
+
+IDbDataParameter param = command.CreateParameter();
+param.Value = 1;
+param.ParameterName = "@0";
+param.DbType = DbType.Int32;
+param.Precision = 0;
+param.Scale = 0;
+param.Size = 0;
+command.Parameters.Add(param);
+
+param = command.CreateParameter();
+param.Value = 2;
+param.ParameterName = "@1";
+param.DbType = DbType.Int32;
+param.Precision	= 0;
+param.Scale = 0;
+param.Size = 0;
+command.Parameters.Add(param);
+
+command.CommandText = "INSERT INTO XXX (X,Y) VALUES (@0, at 1)";
+
+rowCount = command.ExecuteNonQuery();
+System.Console.WriteLine("RowCount returned by ExecuteNonQuery: " + 
+rowCount);
+
+command.CommandText = "select count(*) FROM XXX";
+rowCount = (int)command.ExecuteScalar();
+System.Console.WriteLine("RowCount in database: " + rowCount);
+
+command.CommandText = "DROP TABLE XXX";
+rowCount = command.ExecuteNonQuery();
+
+dbConnection.Close();
+
+
+Actual Results:
+RowCount returned by ExecuteNonQuery: 3
+RowCount in database: 1
+
+Expected Results:
+RowCount returned by ExecuteNonQuery: 1
+RowCount in database: 1
+
+How often does this happen? 
+Always with SybaseClient.
+SQLClient has the correct behavior.
+
+Additional Information:
+
+When using parameters, variables declarations and assignments are added 
+to the sql command sent to the server.  In the above example, here is the 
+sql command that is sent :
+
+declare @0 int
+declare @1 int
+select @0 = 1
+select @1 = 2
+INSERT INTO XXX (X,Y) VALUES (@0, at 1)
+
+
+Sybase returns "1 row affected" for both variables assignments as well as 
+the insert command which leads to the return value of 3 instead of 1.


More information about the mono-bugs mailing list