When dealing with CHAR/VARCHAR columns, and not validating user input, you may have come across this error:
Microsoft OLE DB Provider for SQL Server error '80040e57' String or binary data would be truncated. or Microsoft JET Database Engine (0x80040E57) The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. or Microsoft OLE DB Provider for ODBC Drivers error '80040e57' [Microsoft][ODBC Microsoft Access Driver]Invalid string or buffer length. | Typically, this is caused by trying to insert too many characters into a defined column. For example:
CREATE TABLE #foo (bar CHAR(5)) INSERT #foo(bar) VALUES('yoohoo') | A couple of easy fixes include:
- using client-side methods (e.g. MAXLENGTH or JavaScript) to prevent such data from being submitted;
- adjusting the column definition(s) to accommodate for likely data lengths;
- adjusting the incoming data to fit the column definition, e.g.:
<% bar = replace(left(request.form("bar"),5),"'","''") sql = "INSERT #foo(bar) VALUES('" & bar & "')" ' ... %> |
There may be another reason for this symptom, if you are seeing this error from ASP but do not see it in native tools; for example, Query Analyzer. You can alleviate this by making SET database options consistent -- see KB #255765 for more information.
Microsoft OLE DB Provider for ODBC Drivers error '80040e57' [Microsoft][ODBC Microsoft Access Driver]Numeric value out of range (null) | Check that you are inserting valid numbers into numeric columns. These should not contain any non-numeric characters, and should not be enclosed in quotes.
Microsoft JET Database Engine error '80040e57' Overflow | Make sure you are inserting numeric values into a numeric column, and that it doesn't exceed the capacity of the column. For example, 3,000,000,000 won't fit in a standard Access numeric (or SQL Server INT) column.
Microsoft OLE DB Provider for ODBC Drivers error '80040e07' [Microsoft][ODBC SQL Server Driver][SQL Server] The conversion of a CHAR data type to a DATETIME data type resulted in an out-of-range DATETIME value. or Microsoft OLE DB Provider for ODBC Drivers error '80040e07' [Microsoft][ODBC SQL Server Driver][SQL Server] The conversion of CHAR to DATETIME resulted in a DATETIME value out of range. or Microsoft OLE DB Provider for ODBC Drivers error '80040e07' [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. or Microsoft JET Database Engine error '80040e07' Data type mismatch in criteria expression. | This error usually happens when you do one of the following things:- attempt to insert a date in Access with ' delimiters;
- attempt to insert a date in SQL Server with # delimiters;
- attempt to insert a date in Access or SQL Server with no delimiters; or,
- attempt to insert a malformed date.
If you are using a TEXT column for the first time, you might find that it does not behave the same as CHAR/VARCHAR. You might come across an error like this:
Microsoft OLE DB Provider for SQL Server (0x80040E07) Argument data type text is invalid for argument 1 of len function. | See Article #2061 for a list of workarounds to using standard string functions against TEXT columns.
[ Comment, Edit or Article Submission ]
Share this:
More about:
| Sep |
October 2008 |
Nov |
| Sun |
Mon |
Tue |
Wed |
Thu |
Fri |
Sat |
| |
|
|
1 |
2 |
3 |
4 |
| 5 |
6 |
7 |
8 |
9 |
10 |
11 |
| 12 |
13 |
14 |
15 |
16 |
17 |
18 |
| 19 |
20 |
21 |
22 |
23 |
24 |
25 |
| 26 |
27 |
28 |
29 |
30 |
31 |
|
|
|
|
|