Group,

I'm not sure if this is a SQL Server issue or a Visual Basic issue. However during the runtime, I'm getting the following error message:

String or binary data would be truncated.
The statement has been terminated.

I'm not sure why or where this is being caught. Searching this online indicates that I have a value that is larger in size than what I'm trying to insert. However I'm struggling to find which value it is. Can someone suggest where I could look to find which value is too long?

Thanks,

Don

Recommended Answers

All 5 Replies

I suspect a field length on one of your values you are inserting/updating.

For example:

Dim str As String = "Hello World"

If the length of str is greater than the size of the field (varchar or nvarchar) then you will truncate the data.

Begin by looking at all of the string fields that are being inserted/updated and check those first.

Can you give us a sample of your code or maybe the data that produces the error. Maybe it would be easy for us to discover what's really going on.

  1. It could be the string length (in VB) was longer than the field size (in SQL).
  2. It could be the string returned a NULL value and could not be accpect by SQL.
  3. It could be the LINQ string exceeded max length for a SQL execute string (5000).

this error came when your database field size is smaller then your data.

Regards

I've enlarged the field sizes in the database. That fixed it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.