Debugging: String or binary data would be truncated

L

Lord Merlin

I hope someone can help me with this:

This error gets generated from one of my client's sites, which records a
lot of info via forms. It happened today, when someone tried to make a
comment about a company, yet it's the only time that this error was recorded
while doing a capture. My client has however been complaining for a few days
now, that when she wants to display all comments added for the past 5 days,
she gets that error. On the form is a dropdown that has different industry
categories, and when she choose any of those categories, and it only display
comments for that category it's fine.
If I run the query in enterprise manager, it's fine.

Now, what makes it a bit more interesting. When I run the queries @ night,
when there are less people on the site, it works fine, when I run it during
the day, it gives me this error. Can this directly be related to server
taking strain? Too high CPU / Memory usage?

How would I debug / diagnose such a problem?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
 
R

Ray at

This means that the column in the database accepts a maximum datalength of
n, and the value that your page tried to insert into the database was > n.

Like, if you have a column called Comments with a maximum length of 500 and
someone writes a 600 character paragraph and tries to submit the form, you
page doesn't have anything in place to deal with data that is longer than
the allowed length.

Ray at work
 
B

Bob Barrows

The error is a warning that the string you are attempting to use to set a
column's value is too long to fit into the column which is being used. It
has nothing to do with number of users, memory, etc. It means the string is
too long.

You will need to validate the comment and make sure it will fit into the
column for which it is intended. I can't get specific because I can't see
the code you are using to pass this value to the database.

In the future, please provide the ENTIRE error message. I happened to
recognize this as a database error message, but others might not, causing
them to waste their time and yours with irrelevant suggestions.

Bob Barrows
 
L

Lord Merlin

Hi Bob

I appreciate what you say. The page in question does have JavaScript to
limit the input. Here is the code:

strsubject = Trim(strsubject )
incident = Trim(incident )
solution = Trim(solution )

ticksubscriber = "N"
tickindustry = "N"
companycount = 0

strcomment = GetFormData("strcomment")
subscriber = GetFormData("subscriber")
company_dont = GetFormData("company_dont")
industry = GetFormData("industry")
othersupplier = Trim(GetFormData("othersupplier"))
if subscriber = "0" then
'tickindustry = "Y"
if company_dont ="0" then
else
othersupplier = company_dont
tickindustry = "Y"
end if
else
othersupplier = subscriber
ticksubscriber = "Y"
tickindustry = "Y"
end if
country = GetFormData("country")
province = Trim(GetFormData("strprovince"))
city = Trim(GetFormData("city"))
area = Trim(GetFormData("area"))
person = Trim(GetFormData("person"))
telno = GetFormData("telno")
datemonth = GetFormData("datemonth")
dateday = GetFormData("dateday")
dateyear = GetFormData("dateyear")
timehour = GetFormData("timehour")
timeminute = GetFormData("timeminute")
timeampm = GetFormData("timeampm")
alias = Trim(GetFormData("alias"))
fullname = Trim(GetFormData("fullname"))
emailaddress = Trim(GetFormData("emailaddress"))
tel1 = Trim(GetFormData("telnum1"))
tel2 = Trim(GetFormData("telnum2"))
contacttype = GetFormData("contacttype")

if ((timehour = "") OR (timehour = " ")) then timehour = "1"
if ((timeminute = "") OR (timeminute = " ")) then timeminute = "00"
if ((timeampm = "") OR (timeampm = " ")) then timeampm = "AM"

telnum1 = tel1 & " " & tel2
'currentdate = Now()
currentdate = Month(Date())& "/" & Day(Date())& "/" & Year(Date())& " " &
formatdatetime(now(),3)

tempcompany = othersupplier

thedate = datemonth & "/" & dateday & "/" & dateyear & " " & timehour & ":"
& timeminute & " " & timeampm




InsertQuery="INSERT INTO comments " &_
"(NUserID,thedate, currentdate, commenttype, userid, username,
supplier, person, subject, description, solution, industry, country,
province, city, area, emailsent, clientresponse, compliment,
complaint,telno,subscriber)" &_
" VALUES (" & Session("NUserID") & ", '" &_
thedate & "','" &_
currentdate & "','" &_
strcomment & "'," &_
Session("NUserID") & ",'" &_
alias & "','" &_
Replace(companyname,"'","''") & "','" &_
person & "','" &_
Replace(strsubject, "'", chr(39) & chr(39)) & "','" &_
Replace(incident, "'", chr(39) & chr(39)) & "','" &_
Replace(solution, "'", chr(39) & chr(39)) & "','" &_
industry & "','" &_
country & "','" &_
province & "','" &_
city & "','" &_
area & "','" &_
"no" & "','" &_
"" & "'," &_
compliment & "," &_
complaint & ",'" &_
telno & "','" & ticksubscriber & "');Select @@IDENTITY as id;"



And the Javascript to limit the input:


function checkincident() {
var formname = document.commentform;
var incident = formname.incident.value;

if (incident.length > 1199) {
alert("Please limit your Incident Description to 1200 characters!");
return(false);
}
}

function checksolution() {
var formname = document.commentform;
var solution = formname.solution.value;

if (solution.length > 1199) {
alert("Please limit your Solution to 1200 characters!");
return(false);
}
}


I hope this is useful :)

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
: The error is a warning that the string you are attempting to use to set a
: column's value is too long to fit into the column which is being used. It
: has nothing to do with number of users, memory, etc. It means the string
is
: too long.
:
: You will need to validate the comment and make sure it will fit into the
: column for which it is intended. I can't get specific because I can't see
: the code you are using to pass this value to the database.
:
: In the future, please provide the ENTIRE error message. I happened to
: recognize this as a database error message, but others might not, causing
: them to waste their time and yours with irrelevant suggestions.
:
: Bob Barrows
:
: Lord Merlin wrote:
: > I hope someone can help me with this:
: >
: > Now, what makes it a bit more interesting. When I run the queries @
: > night, when there are less people on the site, it works fine, when I
: > run it during the day, it gives me this error. Can this directly be
: > related to server taking strain? Too high CPU / Memory usage?
: >
: > How would I debug / diagnose such a problem?
:
: --
: Microsoft MVP - ASP/ASP.NET
: Please reply to the newsgroup. This email account is my spam trap so I
: don't check it very often. If you must reply off-line, then remove the
: "NO SPAM"
:
:
 
K

Ken Schaefer

Verify the length of the input on the *server*

a) javascript may not be running on the client
b) javascript may have a bug
c) ??

You can't rely on client-side validation to protect the app, since the code
is running on an untrusted machine completely out of your server's control.
The only benefit to running javascript is to save the user a round-trip. You
need to reverify everything on the server.

Cheers
Ken


: Hi Bob
:
: I appreciate what you say. The page in question does have JavaScript to
: limit the input. Here is the code:
:
: strsubject = Trim(strsubject )
: incident = Trim(incident )
: solution = Trim(solution )
:
: ticksubscriber = "N"
: tickindustry = "N"
: companycount = 0
:
: strcomment = GetFormData("strcomment")
: subscriber = GetFormData("subscriber")
: company_dont = GetFormData("company_dont")
: industry = GetFormData("industry")
: othersupplier = Trim(GetFormData("othersupplier"))
: if subscriber = "0" then
: 'tickindustry = "Y"
: if company_dont ="0" then
: else
: othersupplier = company_dont
: tickindustry = "Y"
: end if
: else
: othersupplier = subscriber
: ticksubscriber = "Y"
: tickindustry = "Y"
: end if
: country = GetFormData("country")
: province = Trim(GetFormData("strprovince"))
: city = Trim(GetFormData("city"))
: area = Trim(GetFormData("area"))
: person = Trim(GetFormData("person"))
: telno = GetFormData("telno")
: datemonth = GetFormData("datemonth")
: dateday = GetFormData("dateday")
: dateyear = GetFormData("dateyear")
: timehour = GetFormData("timehour")
: timeminute = GetFormData("timeminute")
: timeampm = GetFormData("timeampm")
: alias = Trim(GetFormData("alias"))
: fullname = Trim(GetFormData("fullname"))
: emailaddress = Trim(GetFormData("emailaddress"))
: tel1 = Trim(GetFormData("telnum1"))
: tel2 = Trim(GetFormData("telnum2"))
: contacttype = GetFormData("contacttype")
:
: if ((timehour = "") OR (timehour = " ")) then timehour = "1"
: if ((timeminute = "") OR (timeminute = " ")) then timeminute = "00"
: if ((timeampm = "") OR (timeampm = " ")) then timeampm = "AM"
:
: telnum1 = tel1 & " " & tel2
: 'currentdate = Now()
: currentdate = Month(Date())& "/" & Day(Date())& "/" & Year(Date())& " " &
: formatdatetime(now(),3)
:
: tempcompany = othersupplier
:
: thedate = datemonth & "/" & dateday & "/" & dateyear & " " & timehour &
":"
: & timeminute & " " & timeampm
:
:
:
:
: InsertQuery="INSERT INTO comments " &_
: "(NUserID,thedate, currentdate, commenttype, userid, username,
: supplier, person, subject, description, solution, industry, country,
: province, city, area, emailsent, clientresponse, compliment,
: complaint,telno,subscriber)" &_
: " VALUES (" & Session("NUserID") & ", '" &_
: thedate & "','" &_
: currentdate & "','" &_
: strcomment & "'," &_
: Session("NUserID") & ",'" &_
: alias & "','" &_
: Replace(companyname,"'","''") & "','" &_
: person & "','" &_
: Replace(strsubject, "'", chr(39) & chr(39)) & "','" &_
: Replace(incident, "'", chr(39) & chr(39)) & "','" &_
: Replace(solution, "'", chr(39) & chr(39)) & "','" &_
: industry & "','" &_
: country & "','" &_
: province & "','" &_
: city & "','" &_
: area & "','" &_
: "no" & "','" &_
: "" & "'," &_
: compliment & "," &_
: complaint & ",'" &_
: telno & "','" & ticksubscriber & "');Select @@IDENTITY as id;"
:
:
:
: And the Javascript to limit the input:
:
:
: function checkincident() {
: var formname = document.commentform;
: var incident = formname.incident.value;
:
: if (incident.length > 1199) {
: alert("Please limit your Incident Description to 1200 characters!");
: return(false);
: }
: }
:
: function checksolution() {
: var formname = document.commentform;
: var solution = formname.solution.value;
:
: if (solution.length > 1199) {
: alert("Please limit your Solution to 1200 characters!");
: return(false);
: }
: }
:
:
: I hope this is useful :)
:
: --
:
: Kind Regards
: Rudi Ahlers
: +27 (82) 926 1689
:
: Greater love has no one than this, that he lay down his life for his
friends
: (John 15:13).
: : : The error is a warning that the string you are attempting to use to set
a
: : column's value is too long to fit into the column which is being used.
It
: : has nothing to do with number of users, memory, etc. It means the string
: is
: : too long.
: :
: : You will need to validate the comment and make sure it will fit into the
: : column for which it is intended. I can't get specific because I can't
see
: : the code you are using to pass this value to the database.
: :
: : In the future, please provide the ENTIRE error message. I happened to
: : recognize this as a database error message, but others might not,
causing
: : them to waste their time and yours with irrelevant suggestions.
: :
: : Bob Barrows
: :
: : Lord Merlin wrote:
: : > I hope someone can help me with this:
: : >
: : > Now, what makes it a bit more interesting. When I run the queries @
: : > night, when there are less people on the site, it works fine, when I
: : > run it during the day, it gives me this error. Can this directly be
: : > related to server taking strain? Too high CPU / Memory usage?
: : >
: : > How would I debug / diagnose such a problem?
: :
: : --
: : Microsoft MVP - ASP/ASP.NET
: : Please reply to the newsgroup. This email account is my spam trap so I
: : don't check it very often. If you must reply off-line, then remove the
: : "NO SPAM"
: :
: :
:
:
 
L

Lord Merlin

Ok, this is a good point you bring out, and it didn't cross my mind. How
though, would I do it?
I now have two inputs, incident = Trim(incident ) and solution =
Trim(solution ) <- these are the text fields.
what would the code be to check the length of the characters, and what is a
good recommendation todo if the string is longer that 1200 caracters?
Redirect them to a new page, with the same text box, and their text, but
with that which is longer than the 1200 caracters? I can't insert
half-cutoff sentences, so I would need to make them retype say the last
sentense or so.
--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
: Verify the length of the input on the *server*
:
: a) javascript may not be running on the client
: b) javascript may have a bug
: c) ??
:
: You can't rely on client-side validation to protect the app, since the
code
: is running on an untrusted machine completely out of your server's
control.
: The only benefit to running javascript is to save the user a round-trip.
You
: need to reverify everything on the server.
:
: Cheers
: Ken
:
:
: : : Hi Bob
: :
: : I appreciate what you say. The page in question does have JavaScript to
: : limit the input. Here is the code:
: :
: : strsubject = Trim(strsubject )
: : incident = Trim(incident )
: : solution = Trim(solution )
: :
: : ticksubscriber = "N"
: : tickindustry = "N"
: : companycount = 0
: :
: : strcomment = GetFormData("strcomment")
: : subscriber = GetFormData("subscriber")
: : company_dont = GetFormData("company_dont")
: : industry = GetFormData("industry")
: : othersupplier = Trim(GetFormData("othersupplier"))
: : if subscriber = "0" then
: : 'tickindustry = "Y"
: : if company_dont ="0" then
: : else
: : othersupplier = company_dont
: : tickindustry = "Y"
: : end if
: : else
: : othersupplier = subscriber
: : ticksubscriber = "Y"
: : tickindustry = "Y"
: : end if
: : country = GetFormData("country")
: : province = Trim(GetFormData("strprovince"))
: : city = Trim(GetFormData("city"))
: : area = Trim(GetFormData("area"))
: : person = Trim(GetFormData("person"))
: : telno = GetFormData("telno")
: : datemonth = GetFormData("datemonth")
: : dateday = GetFormData("dateday")
: : dateyear = GetFormData("dateyear")
: : timehour = GetFormData("timehour")
: : timeminute = GetFormData("timeminute")
: : timeampm = GetFormData("timeampm")
: : alias = Trim(GetFormData("alias"))
: : fullname = Trim(GetFormData("fullname"))
: : emailaddress = Trim(GetFormData("emailaddress"))
: : tel1 = Trim(GetFormData("telnum1"))
: : tel2 = Trim(GetFormData("telnum2"))
: : contacttype = GetFormData("contacttype")
: :
: : if ((timehour = "") OR (timehour = " ")) then timehour = "1"
: : if ((timeminute = "") OR (timeminute = " ")) then timeminute = "00"
: : if ((timeampm = "") OR (timeampm = " ")) then timeampm = "AM"
: :
: : telnum1 = tel1 & " " & tel2
: : 'currentdate = Now()
: : currentdate = Month(Date())& "/" & Day(Date())& "/" & Year(Date())& " "
&
: : formatdatetime(now(),3)
: :
: : tempcompany = othersupplier
: :
: : thedate = datemonth & "/" & dateday & "/" & dateyear & " " & timehour &
: ":"
: : & timeminute & " " & timeampm
: :
: :
: :
: :
: : InsertQuery="INSERT INTO comments " &_
: : "(NUserID,thedate, currentdate, commenttype, userid, username,
: : supplier, person, subject, description, solution, industry, country,
: : province, city, area, emailsent, clientresponse, compliment,
: : complaint,telno,subscriber)" &_
: : " VALUES (" & Session("NUserID") & ", '" &_
: : thedate & "','" &_
: : currentdate & "','" &_
: : strcomment & "'," &_
: : Session("NUserID") & ",'" &_
: : alias & "','" &_
: : Replace(companyname,"'","''") & "','" &_
: : person & "','" &_
: : Replace(strsubject, "'", chr(39) & chr(39)) & "','" &_
: : Replace(incident, "'", chr(39) & chr(39)) & "','" &_
: : Replace(solution, "'", chr(39) & chr(39)) & "','" &_
: : industry & "','" &_
: : country & "','" &_
: : province & "','" &_
: : city & "','" &_
: : area & "','" &_
: : "no" & "','" &_
: : "" & "'," &_
: : compliment & "," &_
: : complaint & ",'" &_
: : telno & "','" & ticksubscriber & "');Select @@IDENTITY as id;"
: :
: :
: :
: : And the Javascript to limit the input:
: :
: :
: : function checkincident() {
: : var formname = document.commentform;
: : var incident = formname.incident.value;
: :
: : if (incident.length > 1199) {
: : alert("Please limit your Incident Description to 1200 characters!");
: : return(false);
: : }
: : }
: :
: : function checksolution() {
: : var formname = document.commentform;
: : var solution = formname.solution.value;
: :
: : if (solution.length > 1199) {
: : alert("Please limit your Solution to 1200 characters!");
: : return(false);
: : }
: : }
: :
: :
: : I hope this is useful :)
: :
: : --
: :
: : Kind Regards
: : Rudi Ahlers
: : +27 (82) 926 1689
: :
: : Greater love has no one than this, that he lay down his life for his
: friends
: : (John 15:13).
: : : : : The error is a warning that the string you are attempting to use to
set
: a
: : : column's value is too long to fit into the column which is being used.
: It
: : : has nothing to do with number of users, memory, etc. It means the
string
: : is
: : : too long.
: : :
: : : You will need to validate the comment and make sure it will fit into
the
: : : column for which it is intended. I can't get specific because I can't
: see
: : : the code you are using to pass this value to the database.
: : :
: : : In the future, please provide the ENTIRE error message. I happened to
: : : recognize this as a database error message, but others might not,
: causing
: : : them to waste their time and yours with irrelevant suggestions.
: : :
: : : Bob Barrows
: : :
: : : Lord Merlin wrote:
: : : > I hope someone can help me with this:
: : : >
: : : > Now, what makes it a bit more interesting. When I run the queries @
: : : > night, when there are less people on the site, it works fine, when I
: : : > run it during the day, it gives me this error. Can this directly be
: : : > related to server taking strain? Too high CPU / Memory usage?
: : : >
: : : > How would I debug / diagnose such a problem?
: : :
: : : --
: : : Microsoft MVP - ASP/ASP.NET
: : : Please reply to the newsgroup. This email account is my spam trap so I
: : : don't check it very often. If you must reply off-line, then remove the
: : : "NO SPAM"
: : :
: : :
: :
: :
:
:
 
R

roger

Ok, this is a good point you bring out, and it didn't cross my mind. How
though, would I do it?
I now have two inputs, incident = Trim(incident ) and solution =
Trim(solution ) <- these are the text fields.
what would the code be to check the length of the characters, and what is a
good recommendation todo if the string is longer that 1200 caracters?
Redirect them to a new page, with the same text box, and their text, but
with that which is longer than the 1200 caracters? I can't insert
half-cutoff sentences, so I would need to make them retype say the last
sentense or so.

In vbscript that would be -

if len(string) > 1200 then redisplay_data
 
L

Lord Merlin

Thanx Roger

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
: "Lord Merlin" wrote
: > Ok, this is a good point you bring out, and it didn't cross my mind. How
: > though, would I do it?
: > I now have two inputs, incident = Trim(incident ) and solution =
: > Trim(solution ) <- these are the text fields.
: > what would the code be to check the length of the characters, and what
is
: a
: > good recommendation todo if the string is longer that 1200 caracters?
: > Redirect them to a new page, with the same text box, and their text, but
: > with that which is longer than the 1200 caracters? I can't insert
: > half-cutoff sentences, so I would need to make them retype say the last
: > sentense or so.
:
: In vbscript that would be -
:
: if len(string) > 1200 then redisplay_data
:
: --
: roger
:
:
 
L

Lord Merlin

Thanx Roger

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
: "Lord Merlin" wrote
: > Ok, this is a good point you bring out, and it didn't cross my mind. How
: > though, would I do it?
: > I now have two inputs, incident = Trim(incident ) and solution =
: > Trim(solution ) <- these are the text fields.
: > what would the code be to check the length of the characters, and what
is
: a
: > good recommendation todo if the string is longer that 1200 caracters?
: > Redirect them to a new page, with the same text box, and their text, but
: > with that which is longer than the 1200 caracters? I can't insert
: > half-cutoff sentences, so I would need to make them retype say the last
: > sentense or so.
:
: In vbscript that would be -
:
: if len(string) > 1200 then redisplay_data
:
: --
: roger
:
:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top