Avatar of maqskywalker
maqskywalker
 asked on

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

Hi experts,

I saw this example:

ex1.PNG
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

ASP.NETC#

Avatar of undefined
Last Comment
maqskywalker

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Kyle Abrahams, PMP

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
maqskywalker

ASKER
thanks
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck