Create az Sql Server table with nvarchar(max) field and insert into it more than 8000 length string using command
After the field will contain only 8000 chars... The string will be truncated...
SELECT DATALENGTH(bigfield) AS TEXTFieldSize from bigtable; will return 8000.
The problem occured in mono 3.4, it worked without errors in mono 2.9.10...
The problem occures when:
Using explicit type, it works ok:
cmd.Parameters.Add(par.Key, SqlDbType.NVarChar, -1);
cmd.Parameters[par.Key].Value = par.Value;
It seems that automatic parameter type detection fails....
I'm experiencing the same behaviour with a Mac application.
I tried with Mono 3.6 and the behaviour is the same.
I'm trying to save a xml in a nvarchar max and it get truncated.
With a little google search I found that a similar bug was fixed in and earlier version of Mono 2.4.x
I can provide a app that reproduce the issue if need be.
From looking into the code, the problem seems to be in Tds70:WriteParameterInfo (). Its trying to send the data as as NText type, and it gets truncated to 4000 bytes for some reason. Newer versions of sql server/tds has support for the nvarchar(max) type so we should probably send that, but its pretty hard to understand from the tds spec how this type can be emitted.
Corresponding code from jtds:
Fixed in mono master f269254917ea7362bf8248e121303b4756ed6834/mono 3.12 branch a825298e9dbdc5902ba99edeed4dc0f5a62044cb.
Moving to release product/milestone for verification.
Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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.
Create a new report for Bug 21172 on Developer
Community or GitHub if you have new information to add and do not yet see a matching
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
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.