Newbie here. I'm building a web app in c# that uses a database to display results via a variable contained within a dropdown.
So far, I have a procedure that looks like the following;
USE [energyexpenditure]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[getbysID] @schoolID int
as
select *
from energyInvoices
where schoolID=@schoolID
order by dateFiled;
My question is, does/can "schoolID" represent a variable from the webapp? For example, the user selects a school from the dropdown, which sends a variable of "schoolID=1" to represent a specific school. Does SQL interpret that schoolID properly? Or should I be doing something differently?
Edit: Apologies for the terrible format here, I'm very new to this.
Yes, your C# application will indeed be able to assign a value to this parameter.
Assuming an SqlCommand
instance named cmd
:
cmd.Parameters.Add(new SqlParameter("schoolID", 1));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments