Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GetExecScalar Returns Nothing
Message
From
25/10/2004 18:52:21
 
 
To
22/10/2004 15:28:29
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00953138
Message ID:
00954423
Views:
12
Joe,

To modify your code to use a Stored Proc instead of a Function, try this:
CREATE PROCEDURE tsgsp_GetBatchAlreadyProcessedTF 
  @BatchId int,
  @@BatchProcessedTF CHAR(5) OUTPUT
AS
BEGIN
DECLARE @BatchProcessedTF AS CHAR(5)
SELECT @BatchProcessedTF =
   CASE
     WHEN COUNT(DISTINCT BatchId) = 1 THEN 'True'
   ELSE 'False'
   END
FROM ParticipantCheckDetail
WHERE BatchID = @BatchId
END
GO
~~Bonnie


>Kevin, you were correct originally, this is a stored procedure.
>It does not use an output parameter.
>However, I noticed in the information link that you provided regarding using a UDF with ADO.NET that they:
>1. Declared a ReturnValue variable as SqlParameter
>2. Set the ReturnValue.Direction = ParameterDirection.ReturnValue
>3. Used cmd.ExecuteNonQuery to execute the UDF
>
>My breakdown in understanding seems to center on the requirement/usage of an output parameter.
>Do I need to use an output parameter?
>How would I change the following code to correctly use an output parameter and thus correctly return the value of the stored procedure?
>
>Public Function GetBatchAlreadyProcessed(ByVal batchID As Integer) As String
> Dim dao As mmDataAccessBase = Me.GetDataAccessObject
> Dim BatchIdParam As IDbDataParameter = dao.CreateParameter("@BatchId", batchID)
> BatchIdParam.Direction = ParameterDirection.Input
> Return CStr(Me.ExecSprocScalar("tsgsp_GetBatchAlreadyProcessedTF", BatchIdParam))
>End Function
>
>CREATE FUNCTION tsgsp_GetBatchAlreadyProcessedTF (@BatchId int) RETURNS CHAR(5)
>AS
>BEGIN
>DECLARE @BatchProcessedTF AS CHAR(5)
>SELECT @BatchProcessedTF =
> CASE
> WHEN COUNT(DISTINCT BatchId) = 1 THEN 'True'
> ELSE 'False'
> END
>FROM ParticipantCheckDetail
>WHERE BatchID = @BatchId
>RETURN @BatchProcessedTF
>END
>GO
>
>
>THANKS for your patient understanding and assistance!
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform