Skip to main content
Participating Frequently
August 26, 2011
Answered

Calling Stored Procedure Fail

  • August 26, 2011
  • 1 reply
  • 1843 views

I am sure that this is probably an easy answer but please bear with me.

I have a page

defaulredirect.asp

it is receiving form variables from default.asp'

I need to use those form variables in my stored procedure. My procedure works fine in SQL but when I try to add it to my page as a command it doesn't work.

I am not sure what I am doing wrong. I also don't know for sure what details you need. Please be patient with me.

The procedure inserts the form variables into the table ans returns the newly created ID (identity) for further use in my application.

This topic has been closed for replies.
Correct answer bregent

This is what I used to create it.

USE [Expense]
GO

/****** Object:  StoredProcedure [dbo].[InsertExpense]    Script Date: 08/29/2011 13:22:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[InsertExpense]
  @txtExpEmpName int,
  @txtExpEmpSuper int,
  @txtExpDate datetime,
  @RdGrpExpenseType int,
  @txtExpPurpose varchar(50),
  @txtExpAmount int,
  @Identity int OUT
AS
INSERT INTO [Expense].[dbo].[tblExpense]
           ([ExpEmpName]
           ,[ExpEmpSuper]
           ,[ExpDate]
           ,[ExpTypeID]
           ,[ExpPurpose]
           ,[ExpAmount])
     VALUES
           (@txtExpEmpName
           ,@txtExpEmpSuper
           ,@txtExpDate
           ,@RdGrpExpenseType
           ,@txtExpPurpose
           ,@txtExpAmount)
               
SET @Identity = SCOPE_IDENTITY()

GO


Your sproc has 7 parameters, yet you have created 8 in your asp code? What is "cmdInsertRecord.CreateParameter("@RETURN_VALUE", 3, 4)" ?  I don't see that in your sproc. The parameters, including the order you create them, must match exactly.  I've never used a return value type so I'm not sure how it is used. I'll research that but in the mean time, try commenting that out and see if it runs.

1 reply

Participating Frequently
August 26, 2011

Best to show us the entire code from both pages. Also explain what you mean by 'doesn't work'.

er1ca2000Author
Participating Frequently
August 29, 2011

ok, now I get this:

ADODB.Command error '800a0bb9'

Arguments are of the wrong type, are out of  acceptable range, or are in conflict with one another.

/Expense/defaultredirect.asp, line 32

IDK if this will help but when I try to open the command under the bindings column, it tells me that it can't find my procedure in my database.

Participating Frequently
August 29, 2011

It is a numeric field. What do I use for the datatypes?


Can you show us the stored procedure, at least the top where the parameters are defined?