LINQ Large row (64k) not inserted into SQL database

I have a column in SQL varchar (max). Using LINQ, when I try to add a record with a string larger than 64 KB, the value is not stored in the database. I just do:

test.MyString = LargeString; //(over 64k text) mydb.myTable.InsertOnSubmit(test); mydb.SubmitChanges(); 

Is there a limit when using LINQ to SQL? What is the right way to do this?

+4
source share
1 answer

VarChar(Max) supports a string up to 8000 characters long (SQL Server 2k). In 2005, this should not cause errors.

You can use Text fields; for SQL Server 2005+, VarChar(Max) is preferred .

Attention!

text, text, and graphic data types will be removed in a future version of MicrosoftSQL Server. Avoid using these data types in new developments and plan to change applications that currently use them. Use nvarchar (max), varchar (max), and varbinary (max) instead. Fixed and variable data types for storing large non-Unicode and Unicode character and binary data. Unicode data uses the UNICODE UCS-2 character set.

For details on VarChar and Text data types, see


I noticed that you call InsertOnSubmit on mydb and call SubmitChanges on ISNetDB - this is a typo or the cause of the error.

+7
source

All Articles