I have a few textboxes on a web page gui that I need to send to a stored procedure. The user can enter a list of names, account numbers, companies separated by commas. I would then do some parsing and send the list of objects to my stored procedure. My Textboxes would look like this
Name: [ Peter, Paul, Ryan, Julie ]
Account Numbers: [ 001, 002, 003, 004 ]
Companies: [ New Company, Old Company, ]
So I have a profile class that holds a list of names, accounts etc that are mapped to the view model above.
I have a few textboxes on a gui that I need to send to a stored procedure. The user can enter a list of names, account numbers, companies separated by commas. I would then do some parsing and send the list of objects to my stored procedure. My Textboxes would look like this
Name: [ Peter, Paul, Ryan, Julie ]
Account Numbers: [ 001, 002, 003, 004 ]
Companies: [ New Company, Old Company, ]
So I have a profile class that holds a list of names, accounts etc that are mapped to the viewmodel above.
List profiles = new List();
profiles.Names = names;
profiles.AcctNumbers = acctnums;
profiles.Companies = companies;
Then I assign each profile property to a SQL Parameter and pass it to the stored procedure.
My stored procedure would look like this
ALTER PROCEDURE [dbo].[GetUsers]
@Names varchar(100),
@AcctNums varchar(100),
@Companies varchar(100)
Select * from users
where Name in @Names
and AccountNumber in @AcctNums
and Company in @Companies
in theory you would think this would work but it doesn't. The stored procedure returns nothing How can I get my idea to work? Or should I completely revamp my approach towards this issue?
Then I assign each profile property to a SQL Parameter and pass it to the stored procedure.
My stored procedure would look like this
ALTER PROCEDURE [dbo].[GetUsers]
@Names varchar(100),
@AcctNums varchar(100),
@Companies varchar(100)
Select * from users
where Name in @Names
and AccountNumber in @AcctNums
and Company in @Companies
in theory you would think this would work but it doesn't. The stored procedure returns nothing How can I get my idea to work? Or should I completely revamp my approach towards this issue?
EDIT: This is not the same as this answer Not the Same Issue. I need to pass in multiple values into a variable which resides in a stored procedure.
If I use the suggestion I get "Procedure or function GetUsers has too many arguments specified."
That answer is using a simple select statement which is not the same as a stored procedure with variables