Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

asp.net web forms C# , display stored procedure result on label

Hi experts,

I saw this example:

User generated image
How to return Output parameter from Stored Procedure in ASP.Net using C# and VB.Net
https://www.aspsnippets.com/Articles/How-to-return-Output-parameter-from-Stored-Procedure-in-ASPNet-in-C-and-VBNet.aspx

In that example which he gives the sql server and asp.net code.

He has a stored procedures that looks like this:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetFruitName]
      @FruitId INT,
      @FruitName VARCHAR(30) OUTPUT
AS
BEGIN
      SET NOCOUNT ON;
     
      SELECT @FruitName = FruitName
      FROM Fruits
      WHERE FruitId = @FruitId
END

Open in new window



How would I revise that exact same example.
If my stored procedure looked like this.
I just want to display the name of the fruit on the label of the asp.net page for whatever fruitid i submitted in the textbox.

USE [FruitsDB]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[GetFruitNameTest1]
	@FruitId INT

AS
BEGIN
	SET NOCOUNT ON;
	
    SELECT [FruitId]
          ,[FruitName]
    FROM [FruitsDB].[dbo].[Fruits]
	WHERE FruitId = @FruitId
END

GO

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maqskywalker
maqskywalker

ASKER

thanks