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.