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
 Development Tools
 Other Development Tools
 ASP - Test for return value from stored procedure.

Author  Topic 

whitesword
Starting Member

17 Posts

Posted - 2004-08-17 : 21:14:26
Below is a subset of my stored procedure (it does quite a bit more than this, but it has been snipped for space saving.


CREATE PROC MaterialInsert
@material nvarchar(25),
@thick int,
@colour nvarchar(25),
@finish nvarchar(3),
@substrate nvarchar(3),
@manufact nvarchar(3),
@descript nvarchar(50),
@owner nvarchar(20)
AS

-- Declare all local variables
Declare @ins_err int

-- Start our transaction
BEGIN TRAN

-- Insert our new material
INSERT INTO Materials (
MaterialID, Thickness, ColourID, FinishID, SubstrateID,
[Description], Owner, ManufacturerID
)
VALUES (
@material, @thick, @colour, @finish, @substrate,
@descript, @owner, @manufact
)

-- Save the error code (just in case
SELECT @ins_err = @@Error

---------------------------------------
-- Stuff deleted for berevity's sake --
---------------------------------------

-- Check for valid SQL error
IF @ins_err = 0
BEGIN
COMMIT TRAN
RETURN (0)
END
ELSE
BEGIN
ROLLBACK TRAN
RETURN( @ins_err )
END

GO


ASP Code Snippet:

Dim dbConn
Dim rsConn

Set dbConn = New Server.Object( "ADODB.Connection" )
dbConn.Open( "Provider=sqloledb;<blargh>")

strSQL = "MaterialInsert " & _
"@material=" & SQLquote(fldMaterial) & "," & _
"@thick=" & fldThickness & "," & _
"@colour=" & SQlquote(fldColour) & "," & _
"@finish=" & SQlquote(fldFinish) & "," & _
"@substrate=" & SQlquote(fldSubstrate) & "," & _
"@descript=" & SQlquote(fldDescription) & "," & _
"@owner=" & SQlquote(fldOwner) & "," & _
"@manufact=" & SQlquote(fldManufID)

Set rsConn = dbConn.Execute( strSQL )



How am I able to get the return value from the above stored procedure?

Cheers
Roger

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-08-17 : 21:20:55
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlpro01/html/sql01b1.asp
Go to Top of Page

whitesword
Starting Member

17 Posts

Posted - 2004-08-17 : 21:28:06
Not quite what I am after. I can get anything that has been SELECTed just fine, it the RETURN value I am wanting to test.

Oops! I have just realised that I have posted the wring stored procedure script I've posted the correct one now.
Go to Top of Page
   

- Advertisement -