Error with Command.Append

A

audleman

I have an ASP form on my website where a visitor enters information. On
submit, the form calls a stored procedure stores in a MS SQL 2000
database. The stored procedure works most of the time, but every once
in a while I get an error 3421 (Application uses a value of the wrong
type for the current operation) when I try to append the last parameter
in the ASP code, which is a Varchar(500). Here's the relevant code:

STORED PROCEDURE
--------------------------------------------------

CREATE PROCEDURE [dbo].[ap_InsertMyForm]
@fname VarChar(100),
@lname VarChar(100),
@homeAddress VarChar(200),
@address2 VarChar(200),
@city VarChar(50),
@state VarChar(10),
@zip VarChar(20),
@followUpCall VarChar(100),
@howMaterialsFit VarChar(500),
@shareIdeas VarChar(500) <--------------- The offending
parameter


And the ASP Code (I've omitted some unimportant lines)
------------------------------
set cn = server.createobject("ADODB.Connection")
set cmd = server.createobject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandText = "ap_InsertMyForm"
cmd.CommandType = adCmdStoredProc

cmd.Parameters.Append cmd.CreateParameter("@fname", adVarChar,
adParamInput, 100, trim(Request("fName")))
cmd.Parameters.Append cmd.CreateParameter("@lname", adVarChar,
adParamInput, 100, trim(Request("lName")))
cmd.Parameters.Append cmd.CreateParameter("@homeAddress", adVarChar,
adParamInput, 200, trim(Request("Home Address")))
cmd.Parameters.Append cmd.CreateParameter("@address2", adVarChar,
adParamInput, 200, trim(Request("Address Line 2")))
cmd.Parameters.Append cmd.CreateParameter("@city", adVarChar,
adParamInput, 50, trim(Request("City")))
cmd.Parameters.Append cmd.CreateParameter("@state", adVarChar,
adParamInput, 10, trim(Request("State")))
cmd.Parameters.Append cmd.CreateParameter("@zip", adVarChar,
adParamInput, 20, trim(Request("Zip")))
cmd.Parameters.Append cmd.CreateParameter("@followUpCall", adVarChar,
adParamInput, 100, trim(Request("Follow-Up Call Or E-mail")))
cmd.Parameters.Append cmd.CreateParameter("@howMaterialsFit",
adVarChar, adParamInput, 500, trim(Request("How can our materials
fit")))
cmd.Parameters.Append cmd.CreateParameter("@shareIdeas", adVarChar,
adParamInput, 500, trim(Request("Please share your ideas")))
<------------- Offending line


It's the final parameter that's sometimes throwing the error. It
doesn't throw it always, and I can't tell what it might be about the
text people input that could cause it. The last time the error was
thrown, this was the text the person had entered:

"I believe that it is our obligation to inspire the children in our
lives to look at a broader perspective and encourage crital thinking
for our communities and our future."

Does anybody have a clue as to what's wrong with my code?

Thank you,
Kevin Audleman
 

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,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top