Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 problem returning @@identity, AAHHHGGGG

Author  Topic 

Ayeidea
Starting Member

17 Posts

Posted - 2001-10-24 : 13:57:13
First of all, i am new to SQL7 and Stored Procedures. on my site im inserting a product thru a StorProc. and trying to return back to the page the product id that it created. here is my code, can someone point out my mistake here.

here is the stored procedure:
quote:
CREATE PROCEDURE [InsertBrandSproc]
( @LeagueID [int],
@Product_Type [varchar](255),
@Brand [varchar](255),
@Product_Name [varchar](255),
@Product_Description [varchar](255),
@Picture_ID [varchar](255),
@Picture_ID_T [varchar](255),
@Price [money],
@Weight [int],
@Quanity [int],
@theID [int] OUTPUT


)

AS
Declare @newID int

SET NOCOUNT ON
INSERT INTO [akolade].[akolade].[products]
( [LeagueID],
[Product_Type],
[Brand],
[Product_Name],
[Product_Description],
[Picture_ID],
[Picture_ID_T])

VALUES
( @LeagueID,

@Product_Type,

@Brand,
@Product_Name,
@Product_Description,
@Picture_ID,
@Picture_ID_T)

SELECT @newid = @@IDENTITY


INSERT INTO [akolade].[akolade].[Prod_Supply]
( [ProdID],
[Quanity],
[Price],
[Weight]
)

VALUES
( @newid,
@Quanity,
@Price,
@Weight )

set @theID = @newid

SET NOCOUNT OFF


here is the asp code
quote:
set insertBrand = Server.CreateObject("ADODB.Command")
insertBrand.ActiveConnection = MM_onlineSQL_STRING
insertBrand.CommandText = "akolade.InsertBrandSproc"
insertBrand.CommandType = adCmdStoredProc
insertBrand.CommandTimeout = 0
insertBrand.Prepared = true
insertBrand.Parameters.Append insertBrand.CreateParameter("RETURN_VALUE",adInteger, adParamReturnValue, 4)
insertBrand.Parameters.Append insertBrand.CreateParameter("@LeagueID", adInteger, adParamInput,4,insertBrand__LeagueID)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Product_Type", adVarChar, adParamInput,30,insertBrand__Product_Type)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Brand", adVarChar, adParamInput,30,insertBrand__Brand)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Product_Name", adVarChar,adParamInput,30,insertBrand__Product_Name)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Product_Description", adVarChar, adParamInput,255,insertBrand__Product_Description)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Picture_ID", adVarChar, adParamInput,30,insertBrand__Picture_ID)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Picture_ID_T", adVarChar, adParamInput,30,insertBrand__Picture_ID_T)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Price", adCurrency, adParamInput,4,insertBrand__Product_Price)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Weight", adInteger, adParamInput,4,insertBrand__Product_Weight)
insertBrand.Parameters.Append insertBrand.CreateParameter("@Quanity", adInteger, adParamInput,4,insertBrand__Product_Price)
insertBrand.Parameters.Append insertBrand.CreateParameter("theID",adInteger, adParamReturnValue, 4)
set rsNewProdID = insertBrand.Execute
rsNewProdID_numRows = 0
Dim newid

newid = rsNewProdID("theID")
response.write newid


someone please help!

Edited by - Ayeidea on 10/24/2001 13:58:14
   

- Advertisement -