CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
>>Development (Web and Desktop) >> Web Development >> ASP (Active Server Pages)

Microsoft OLE DB Provider for SQL Server error '80040e57' String or binary data would be truncated. or The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.

Article ID: 98 - Date Created Friday, February 04, 2011 - This Article Has been Viewed 17528 times.
Article was last updated on: Saturday, June 25, 2011 - Written By:

Microsoft OLE DB Provider for SQL Server error '80040e57' String or binary data would be truncated. or The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.

CFF Knowledge Base - Share on MySpace CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
Share With Friends (Updated 6-8-2010)
If you are inserting data that is larger than the set LENGTH of your data LENGTH. You will receive the following error, The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.

Details
If you are trying to INSERT or UPDATE your data Column with data that is longer than your Database COLUMN LENGTH (or) Your Parameterized Query length.

Both Scenario's can be easily fixed.

There are 2 Different errors you can get.
Access Database Error is:
 
Microsoft Access Database Engine error '80040e57'
The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.
/encrypt.asp, line 28


SQL Server will give the following error
 
Microsoft OLE DB Provider for SQL Server error '80040e57'
String or binary data would be truncated.
/encrypt.asp, line 28


Recreate Issue
This issue will happen if you are trying to INSERT or UPDATE your database Column with a LENGTH that is longer than the set LENGTH either within
Scenario #1:
If the length in your Database LENGTH is not set high enough

Scenario #2:
If the length in your Paramertized Query is not set high enough to allow for the given data to be passed through.


Resolve Issue
To resolve this issue.

Scenario #1:
Make sure that your Database Column's LENGTH is set to a large enough number that will allow for the data to be inserted.

Scenario #2:
If you are using Parameterized Queries in your ASP Code, make sure that the database LENGTH column is at a high enough value.
Example:
If you have your Database Column LENGTH set to 25 and you are using MD5, then you are going to have to allow for the length change,
So: 25 Character LENGTH
Would become [50]
insIm.Parameters.Append insIm.CreateParameter("@myPW", adVarChar, adParamInput, 50, getMyPW)