Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrong number of arguments error

Status
Not open for further replies.

mbaddar

Programmer
May 10, 2001
120
US
Hi,

I haven't worked with ASP for a little while so I'm kind of rusty. Right now, I'm just trying to call a stored procedure from an ASP page. The procedure is only taking one argument and I'm just trying to pass it a hard-coded string.

I keep receiving a wrong number of arguments or arguments of invalid type error. I looked at my stored procedure and that seems correct. There is not going to be a middle tier with this app, so there's nothing there to look at.

I've pasted the code below. Can anyone tell me if they see anything wrong?

Thanks!


<%
Dim objRS, objComm, objParam, strFirstName, objConn, strConn

strConn = &quot;Driver={SQL Server}; Server=(local); Database=DE; UID=sa; PWD=;&quot;

set objComm = server.CreateObject(&quot;ADODB.Command&quot;)

objComm.ActiveConnection = strConn

objComm.CommandText = &quot;sp_InsertCustomers&quot;

objComm.CommandType = adCmdStoredProc

objComm.Parameters.Append objComm.CreateParameter
(&quot;@FirstName&quot;,adVarChar, adParamInput, 30, &quot;Jim&quot;)

objComm.Execute

 
Have you tried taking out the &quot;@&quot; from the param name when you are appending it as I don't think its needed?

Simon
 
couple of things:
* i guess it could work feeding a connection string to a command object, but my preference is always to create and open a connection object, and pass that to the command object
* without seeing your SProc it's hard to judge, but have you tried changing the asp param type to something like adChar?
* and .. aha .. you're telling it you're going to give it a string 30 chars long, and you're actually feeding it a string only 3 chars long - change the 30 to a len(&quot;Jim&quot;) codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top