Avatar of JamesAnthony
JamesAnthony
Flag for Ireland asked on

Calling Stored Procedure VB.net

Hi
What I am trying to do (Excuse syntax, its not meant to run, just a roadmap.)
crate MANY stored procedures
Most have up to 3 parameters
I want my vb code to call procedures and supply only relevant parameters
So my stored procedure is like
alter procedure
as
Param1 int = 0, Param2 int = 0, Param3 char(20) = ' ', param4 char(20) = ' ', param5 Datimtime = getdate(), Param6 Datetime = GetDate()
My first procedure uses Param1 and param5
My Second procedure uses Param2 and param4
My first procedure uses Param1 and param6
Etc etc etc
Can the code be written to only supply these values or do I have to supply for alll params.
Hope this makes sense
And if so an example woould be great
Thanks

Microsoft SQL Server 2005Visual Basic.NET

Avatar of undefined
Last Comment
ralmada

8/22/2022 - Mon
ralmada

you cannot do it so that you only specify param2 and 4 as you want. The only possibility is what's described below:
http://geekswithblogs.net/whiletrue/archive/2009/02/28/optional-parameters-in-sql-stored-procedures.aspx 
ASKER CERTIFIED SOLUTION
valkyrie_nc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ralmada

the other possibility is that you try something like below
 

exec yourprocedure @param2 = 1, @param4 = 'something'

exec yourprocedure @param1 = 0, @param5 = 'something'

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy