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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ReturnValue Problem

Status
Not open for further replies.

gny

Programmer
Jun 3, 2001
116
SE
Why won´t this work?
I´m trying to add a new record in an sp and return the new ID to an asp page. On the row with the Execute-command in the asp code I get the following error message:
Code:
Microsoft OLE DB Provider for SQL Server (0x80040E07)
Error converting data type varchar to int
Heres the sp code:
Code:
CREATE PROCEDURE dbo.sp_AddOrder

	@nNewID		int OUTPUT,
	@sCreatedBy	varchar(50)
AS
	INSERT 
		OD_Order
		(
			CREATED_BY
		)
	VALUES
		(
			@sCreatedBy
		)
	SET @nNewID = @@IDENTITY

And the asp code:
Code:
	dim comNew	
	set comNew=server.createObject("ADODB.Command")
	comNew.ActiveConnection = conn
	comNew.CommandType = adCmdStoredProc
	comNew.CommandText = "sp_AddOrder"
	'*** Sätt inparametrar
	comNew.Parameters.Append comNew.CreateParameter("nNewID", adInteger, adParamReturnValue, 0, 0)'adParamReturnValue, 0, 0)
	comNew.Parameters.Append comNew.CreateParameter("sCREATED_BY", adVarchar, adParamInput, 50, Request("REMOTE_ADDR"))

	comNew.Execute
        session("OD_ID") = comNew.Parameters("nNewID")
It seems as though the first parameter isn´t noticed... What am I doing wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top