troubleshooting Question

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

Avatar of maqskywalker
maqskywalker asked on
ASP.NETC#
2 Comments1 Solution493 ViewsLast Modified:
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


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
ASKER CERTIFIED SOLUTION
Kyle Abrahams
Director of Information Technology

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros