Solved

ODBC Drivers error '80040e57' on SQL Insert

Posted on 2006-11-02
6
297 Views
Last Modified: 2012-06-27
I've seen this posted and answered, but it doesn't fix my issue.

Here is my code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
Dim cnnC3DB
Set cnnC3DB = Server.CreateObject("ADODB.Connection")
cnnC3DB.Open "Driver={SQL Server};" & _
           "Server=xxxxxxx;" & _
           "Database=xxxxxxx;" & _
           "Uid=xxxxxx;" & _
           "Pwd=xxxxxxx"

dim disk_number, classification, title, location, release_date, language, color_code, format
disk_number=request.form("disk_number")
classification=request.form("classification")
title=request.form("title")
location=request.form("location")
release_date=request.form("release_date")
language=request.form("language")
color_code=request.form("color_code")
format=request.form("format")

dim SQL
SQL = "INSERT INTO software (disk_num, classification, title, location, rel_date, lang, color_code, format) VALUES ('"&disk_number&"','"&classification&"','"&title&"','"&location&"','"&release_date&"','"&language&"','"&color_code&"','"&format&"')"

cnnC3DB.Execute(SQL)

cnnC3DB.Close
Set cnnC3DB = Nothing
Set disk_number = Nothing
%>

all datatypes are char, with plenty of space.  I have read that the cause is too many characters into too small of a field.  All fields except from primary key have nulls allowed.  I will get this error even if I submit without any data.  I have also tried with one character in each field.


any ideas?
0
Comment
Question by:darrennelson
  • 4
  • 2
6 Comments
 

Author Comment

by:darrennelson
ID: 17862419
more info:

the full error is:

Microsoft OLE DB Provider for ODBC Drivers error '80040e57'

[Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated.

/msdn2/input.asp, line 25

line 25:
cnnC3DB.Execute(SQL)
0
 
LVL 12

Expert Comment

by:Preece
ID: 17862440
Do this and look for a missing or extra quote:

response.write SQL

Preece
0
 
LVL 12

Expert Comment

by:Preece
ID: 17862456
Or, you may find that one of your fields is filled with a lot of spaces...

Preece
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:Preece
ID: 17862470
If you have unneeded spaces in front or behind, you can trim each field:

disk_number=trim(request.form("disk_number"))
classification=trim(request.form("classification"))
title=trim(request.form("title"))
location=trim(request.form("location"))
release_date=trim(request.form("release_date"))
language=trim(request.form("language"))
color_code=trim(request.form("color_code"))
format=trim(request.form("format"))

Hope that helps,
Preece
0
 
LVL 12

Accepted Solution

by:
Preece earned 125 total points
ID: 17862505
You said that your datatypes are char.  I would go with varchars, as it saves space in your db.  Also, I think that if you retrieve the string "test" from a char(10), for example, you'll get "test      ".  So you may be populating your fields with extra spaces without realizing it...

Also, you may want to limit the textbox sizes to match the defined field sizes in your db:

<input type=text maxlength=5>

Preece
0
 

Author Comment

by:darrennelson
ID: 17868426
thanks Preece, all is working.  I actually implemented all suggestions at the same time, so I'm not sure which fixed it.  I am going to undo all changes, then redo one at a time for personal reference.

Thanks again
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now