Bug 19950 - SqlDataReader::ExecuteReader() differs from Microsoft.NET
Summary: SqlDataReader::ExecuteReader() differs from Microsoft.NET
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-05-20 23:38 UTC by Christopher Pereira
Modified: 2018-02-22 22:36 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Christopher Pereira 2014-05-20 23:38:23 UTC
In Mono 2.11.4 (and other versions), SqlDataReader::ExecuteReader() is not working in the same way as Microsoft.NET.

--- Example ---

SqlConnection myConnection = new SqlConnection("user id=<user>;password=<pw>;server=<host>,<port>;database=<db>");
myConnection.Open();

SqlCommand myCommand;
SqlDataReader reader;

myCommand = new SqlCommand("BEGIN TRANSACTION", myConnection);

// BUG: Doesn't work on Mono, but works on Microsoft.NET
reader = myCommand.ExecuteReader();
reader.close();

// OK: Works fine on Mono and Microsoft.NET
// myCommand.ExecuteNonQuery();

---

The same occurs for other NonQuery commands like "SET IDENTITY_INSERT <table> ON".
This is breaking MSSQL Support on Phalanger (see: https://github.com/DEVSENSE/Phalanger/issues/29)
Comment 1 Christopher Pereira 2014-05-21 00:11:56 UTC
I forgot to mention that using ExecuteReader() instead of ExecuteNonQuery() for the command "BEGIN TRANSACTION" generates the following error with Mono (not with MS.NET):

Command execution failed: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
Comment 2 Marek Safar 2018-02-22 22:36:15 UTC
Mono 5.10 has significantly improved System.Data implementation which should resolve this issue. If you can still reproduce it please reopen the issue.