Calling stored function using user input variable

user3560094

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.

David Hedlund

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));

See example here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a function recursively for user input

From Dev

Calling a function recursively for user input

From Dev

Calling a function, stored as a value in a dictionary, if the user's input matches the value's key

From Dev

Calling function from input variable

From Dev

Calling a function with a variable input in Python

From Java

JavaScript: Access 'this' when calling function stored in variable

From Dev

Join table in Stored Procedure using variable input

From Dev

Calling a function using variable name in VBA

From Dev

Calling a variable in a different function without using global

From Dev

Python, Calling a function again based on input from user

From Dev

calling class with user input

From Dev

calling class with user input

From Dev

How to store user input in a variable using a For Loop?

From Dev

How to create a global variable using user input

From Dev

Calling a method (stored in a variable) in a closure

From Dev

MySql - Creating Stored Function and Calling It

From Dev

Trouble using readline() user input with survfit function

From Dev

calling a function with input

From Dev

Calling stored procedure from PHP using PDO to MSSQL Server using INPUT Paramters

From Dev

Extend a function stored in a variable

From Dev

Calling Stored Procedure using Knime

From Dev

Calling stored procedure using VBA

From Dev

Encoding user input to be stored in MongoDB

From Dev

Haskell - User Input Stored in a List

From Dev

Calling a function as object variable?

From Dev

undefined variable on calling function

From Dev

Calling a function with a variable

From Dev

Calling a function from a child directive & using a variable in the parent directive

From Dev

How to write a bash function that saves user input to new variable names

Related Related

  1. 1

    Calling a function recursively for user input

  2. 2

    Calling a function recursively for user input

  3. 3

    Calling a function, stored as a value in a dictionary, if the user's input matches the value's key

  4. 4

    Calling function from input variable

  5. 5

    Calling a function with a variable input in Python

  6. 6

    JavaScript: Access 'this' when calling function stored in variable

  7. 7

    Join table in Stored Procedure using variable input

  8. 8

    Calling a function using variable name in VBA

  9. 9

    Calling a variable in a different function without using global

  10. 10

    Python, Calling a function again based on input from user

  11. 11

    calling class with user input

  12. 12

    calling class with user input

  13. 13

    How to store user input in a variable using a For Loop?

  14. 14

    How to create a global variable using user input

  15. 15

    Calling a method (stored in a variable) in a closure

  16. 16

    MySql - Creating Stored Function and Calling It

  17. 17

    Trouble using readline() user input with survfit function

  18. 18

    calling a function with input

  19. 19

    Calling stored procedure from PHP using PDO to MSSQL Server using INPUT Paramters

  20. 20

    Extend a function stored in a variable

  21. 21

    Calling Stored Procedure using Knime

  22. 22

    Calling stored procedure using VBA

  23. 23

    Encoding user input to be stored in MongoDB

  24. 24

    Haskell - User Input Stored in a List

  25. 25

    Calling a function as object variable?

  26. 26

    undefined variable on calling function

  27. 27

    Calling a function with a variable

  28. 28

    Calling a function from a child directive & using a variable in the parent directive

  29. 29

    How to write a bash function that saves user input to new variable names

HotTag

Archive