Showing posts with label pagemicrosoft. Show all posts
Showing posts with label pagemicrosoft. Show all posts

Thursday, March 22, 2012

ASP error with stored procedure

SQL Server 2000 on Windows 2003 SP1 and IIS6
I'm getting the following error from my ASP page:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Formal parameter '@.mname' was defined as OUTPUT but the actual parameter
not declared OUTPUT.
However, the formal parameter '@.mname' was used in a previous stored
procedure accessed by the same command object and that parameter has been
been deleted prior to the call.
Here's the DDL for the procedure:
CREATE PROCEDURE InsertAndIdentifyNewStarter
@.peopleID INTEGER,
@.newstarterID BIGINT OUTPUT
AS
INSERT INTO newstarter (peopleID)
VALUES (@.peopleID)
SELECT @.newstarterID = SCOPE_IDENTITY()
GO
And the code snippet that's giving the problem:
Dim cmd, ln
Set cmd = Server.CreateObject("ADODB.Command")
With cmd
.ActiveConnection = "Provider=" & DBPROVIDER & ";" & CONNECTIONSTRING
.CommandType = adCmdStoredProc
.CommandText = "InsertAndIdentifyPerson"
.Parameters.Append .CreateParameter("@.fname", adVarChar, _
adParamInput, 100, firstname)
.Parameters.Append .CreateParameter("@.mname", adVarChar, _
adParamInput, 100, middlename)
.Parameters.Append .CreateParameter("@.sname", adVarChar, _
adParamInput, 100, lastname)
.Parameters.Append .CreateParameter("@.fullname", adVarChar, _
adParamInput, 200, firstname & " " & lastname)
.Parameters.Append .CreateParameter("@.datestarted", adDBDate, _
adParamInput, 10, DBStartDate)
.Parameters.Append .CreateParameter("@.enabled", adInteger, _
adParamInput, 10, 1)
.Parameters.Append .CreateParameter("@.existsinaccounts", _
adInteger, adParamInput, 10, 0)
.Parameters.Append .CreateParameter("@.loggedon", adInteger, _
adParamInput, 10, 0)
.Parameters.Append .CreateParameter("@.itstatus", adInteger, _
adParamInput, 10, 5) ' 5 = New Starter
.Parameters.Append .CreateParameter("@.pID", adInteger, _
adParamOutput, 10)
.Execute ln, , adExecuteNoRecords
pID = .Parameters("@.pID")
' Delete the parameters so that we can reuse the command object
While .Parameters.Count > 0
.Parameters.Delete 0
Wend
' Create a newstarter record for this person
.CommandText = "InsertAndIdentifyPerson"
.Parameters.Append .CreateParameter("@.peopleID", adBigInt, _
adParamInput, 10, pID)
.Parameters.Append .CreateParameter("@.newstarterID", _
adBigInt, adParamOutput, 10)
.Execute ln, , adExecuteNoRecords
' ** The preceding line produces the error **
newstarterID = .Parameters("@.newstarterID")
End With
Set cmd = Nothing
Any ideas what I'm doing wrong or what the problem is?
TIA,
Geoff> CREATE PROCEDURE InsertAndIdentifyNewStarterd">
> snip
> .CommandText = "InsertAndIdentifyPerson"
It looks to me like you are executing the wrong proc.
Hope this helps.
Dan Guzman
SQL Server MVP
"Geoff Lane" <geoff@.nospam.gjctech.co.uk> wrote in message
news:Xns97EA7C83661FBgjctcswxnsrt@.207.46.248.16...
> SQL Server 2000 on Windows 2003 SP1 and IIS6
> I'm getting the following error from my ASP page:
> Microsoft OLE DB Provider for SQL Server error '80040e14'
> Formal parameter '@.mname' was defined as OUTPUT but the actual parameter
> not declared OUTPUT.
> However, the formal parameter '@.mname' was used in a previous stored
> procedure accessed by the same command object and that parameter has been
> been deleted prior to the call.
> Here's the DDL for the procedure:
> CREATE PROCEDURE InsertAndIdentifyNewStarter
> @.peopleID INTEGER,
> @.newstarterID BIGINT OUTPUT
> AS
> INSERT INTO newstarter (peopleID)
> VALUES (@.peopleID)
> SELECT @.newstarterID = SCOPE_IDENTITY()
> GO
> And the code snippet that's giving the problem:
> Dim cmd, ln
> Set cmd = Server.CreateObject("ADODB.Command")
> With cmd
> .ActiveConnection = "Provider=" & DBPROVIDER & ";" & CONNECTIONSTRING
> .CommandType = adCmdStoredProc
> .CommandText = "InsertAndIdentifyPerson"
> .Parameters.Append .CreateParameter("@.fname", adVarChar, _
> adParamInput, 100, firstname)
> .Parameters.Append .CreateParameter("@.mname", adVarChar, _
> adParamInput, 100, middlename)
> .Parameters.Append .CreateParameter("@.sname", adVarChar, _
> adParamInput, 100, lastname)
> .Parameters.Append .CreateParameter("@.fullname", adVarChar, _
> adParamInput, 200, firstname & " " & lastname)
> .Parameters.Append .CreateParameter("@.datestarted", adDBDate, _
> adParamInput, 10, DBStartDate)
> .Parameters.Append .CreateParameter("@.enabled", adInteger, _
> adParamInput, 10, 1)
> .Parameters.Append .CreateParameter("@.existsinaccounts", _
> adInteger, adParamInput, 10, 0)
> .Parameters.Append .CreateParameter("@.loggedon", adInteger, _
> adParamInput, 10, 0)
> .Parameters.Append .CreateParameter("@.itstatus", adInteger, _
> adParamInput, 10, 5) ' 5 = New Starter
> .Parameters.Append .CreateParameter("@.pID", adInteger, _
> adParamOutput, 10)
> .Execute ln, , adExecuteNoRecords
> pID = .Parameters("@.pID")
> ' Delete the parameters so that we can reuse the command object
> While .Parameters.Count > 0
> .Parameters.Delete 0
> Wend
> ' Create a newstarter record for this person
> .CommandText = "InsertAndIdentifyPerson"
> .Parameters.Append .CreateParameter("@.peopleID", adBigInt, _
> adParamInput, 10, pID)
> .Parameters.Append .CreateParameter("@.newstarterID", _
> adBigInt, adParamOutput, 10)
> .Execute ln, , adExecuteNoRecords
> ' ** The preceding line produces the error **
> newstarterID = .Parameters("@.newstarterID")
> End With
> Set cmd = Nothing
> Any ideas what I'm doing wrong or what the problem is?
> TIA,
> --
> Geoff|||"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in
news:elcHsWflGHA.5044@.TK2MSFTNGP02.phx.gbl:

> It looks to me like you are executing the wrong proc.
D'Oh! That'll teach me to cut-and-paste code :(
Thanks - you are correct!
Geoff