Print Page | Close Window

Pass string of values to stored procedure

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=5484
Printed Date: 29 March 2026 at 6:48am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Pass string of values to stored procedure
Posted By: jamesb
Subject: Pass string of values to stored procedure
Date Posted: 03 September 2003 at 10:32am

I have a large web form - with 35 different textboxes, radiobuttons, drop-downs etc on it. I've written code to automatically parse through the controls on the page when it's submitted, and put all the values entered by the user into a string (could easily be an array of course). The problem I now have is whether there is any way to somehow automate this "string of values" being entered into the sql string (or stored procedure) to be sent to the database. Or am I going to have to write it all out as follows:

(CommandObj.Parameters.Add( "@FirstName", FirstName))
(CommandObj.Parameters.Add( "@Surname", Surname))

etc

Surely there must be a way to loop through the string, each time adding the value to the procedure, and not have to hard-code it 35 times? (I build a lot of similar forms and it would be nice to automate it somehow). If it can't be done with a stored procedure, then perhaps with a plain sql statement?

Thanks for any help




Replies:
Posted By: MorningZ
Date Posted: 03 September 2003 at 11:08am

I'd build (and do) a SQL string, a la:

sp_ThisProcThatDoesSomething 'Some String Value', 1, 'Another String'

etc



-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net