Stored Procedure with parameters in ASP.Net
Posted on 2014-04-27
I have a stored procedure in SQL Server I am using to search records and return them for display in an asp.net page (c# code behind). I have 3 parameters I need to use. Owner, Year and Type. By default the page opens to all owners for the current year of both types. Using drop down lists, users can select which owner, what year and which type to return. There are 12 owners, with data from each year for 2009-2014. There are two types to select from. I'm trying to create the stored procedure to select 1 owner OR all owners for a particular year, with either type 1 or type 2. I think I need an if statement or case statement in the stored procedure, but I don't know where to look to find examples. Am I approaching this right, and is there a good example to work with?