Bug 4660 - Mono 2.11.1 Insert and update of MSSQL fails.
Summary: Mono 2.11.1 Insert and update of MSSQL fails.
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2012-04-26 05:45 UTC by Mikkel Kruse Johnsen
Modified: 2017-09-01 09:29 UTC (History)
2 users (show)

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


Attachments
You may pass either 0 or -1 as initial value of sp_prepare's @Handle parameter, but not null. (720 bytes, patch)
2012-06-18 04:15 UTC, Mikkel Kruse Johnsen
Details


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 Mikkel Kruse Johnsen 2012-04-26 05:45:46 UTC
Running on

			string query =
				"UPDATE CUSTTABLE SET" +
				" [NAME]=@NAME" +
				" WHERE" +
				"  [DATASET]=@DATASET" +
				"  AND [ACCOUNT]=@ACCOUNT";

			using (IDbCommand cmd = conn.CreateCommand ())
			{
				cmd.CommandText = query;
			
				IDbDataParameter parm;
				IDataParameterCollection dpc = cmd.Parameters;
				
				parm = cmd.CreateParameter ();
				parm.ParameterName = "@DATASET";
				parm.DbType = DbType.String;
				parm.Size = 3;
				parm.Value = (dataset != null && dataset.Trim ().Length > 0) ? dataset : null;
				dpc.Add (parm);
	
				parm = cmd.CreateParameter ();
				parm.ParameterName = "@ACCOUNT";
				parm.DbType = DbType.String;
				parm.Size = 10;
				parm.Value = (account != null && account.Trim ().Length > 0) ? account.Trim ().PadLeft (10) : null;
				dpc.Add (parm);

				parm = cmd.CreateParameter ();
				parm.ParameterName = "@NAME";
				parm.DbType = DbType.String;
				parm.Size = 30;
				parm.Value = (name != null && name.Trim ().Length > 0) ? name : Convert.ToString ((char)2);
				dpc.Add (parm);

				cmd.Prepare ();
				cmd.ExecuteNonQuery ();
			}

Running on Mono 2.11.1 Gives:

The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 ("@Handle"): Data type 0x26 has an invalid data length or metadata length.
  at System.Data.SqlClient.SqlConnection.ErrorHandler (System.Object sender, Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x00032] in /home/mkj/rpm/BUILD/mono-2.11.1/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs:316 
  at Mono.Data.Tds.Protocol.Tds.OnTdsErrorMessage (Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x0000b] in /home/mkj/rpm/BUILD/mono-2.11.1/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1698 
  at Mono.Data.Tds.Protocol.Tds.ProcessMessage (TdsPacketSubType subType) [0x000ef] in /home/mkj/rpm/BUILD/mono-2.11.1/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1738 
  at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x0012a] in /home/mkj/rpm/BUILD/mono-2.11.1/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1790 
  at Mono.Data.Tds.Protocol.Tds.NextResult () [0x0004a] in /home/mkj/rpm/BUILD/mono-2.11.1/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:619 
  at Mono.Data.Tds.Protocol.Tds.SkipToEnd () [0x00005] in /home/mkj/rpm/BUILD/mono-2.11.1/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:692 
  at Mono.Data.Tds.Protocol.Tds70.Prepare (System.String commandText, Mono.Data.Tds.TdsMetaParameterCollection parameters) [0x0006e] in /home/mkj/rpm/BUILD/mono-2.11.1/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs:790 
  at System.Data.SqlClient.SqlCommand.Prepare () [0x000a9] in /home/mkj/rpm/BUILD/mono-2.11.1/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs:740 
  at OpenMedicus.CustTableC5Data.SaveInsert (IDbConnection conn, IDbTransaction t) [0x00000] in <filename unknown>:0 
  at OpenMedicus.CustTableC5Data.Save (IDbConnection conn, IDbTransaction t) [0x00000] in <filename unknown>:0 
  at OpenMedicus.DynamicsC5Debitor.OnDebitorSyncCallback (System.Object obj, System.EventArgs args) [0x00000] in <filename unknown>:0



Running on Mono 2.10.8 it works fine
Comment 1 Mikkel Kruse Johnsen 2012-05-22 09:58:20 UTC
Anyone looking at this ?
Comment 2 Mikkel Kruse Johnsen 2012-05-24 03:17:52 UTC
It works fine if you don't use parameters.
Comment 3 Mikkel Kruse Johnsen 2012-06-18 04:15:25 UTC
Created attachment 2074 [details]
You may pass either 0 or -1 as initial value of sp_prepare's @Handle parameter, but not null.

You may pass either 0 or -1 as initial value of sp_prepare's @Handle parameter, but not null.  Tested with MS SQL 2008 RC2 Express and MS SQL 2012 Express.

Taken from this bug report:

http://wrench.mono-project.com/Wrench/GetRevisionLog.aspx?id=10710

It works on mono 2.11.1 and tested from Linux to MSSQL 2008.