Solved

Calling Stored Procedure VB.net

Posted on 2010-09-13
3
281 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:JamesAnthony
  • 2
3 Comments
 
LVL 41

Expert Comment

by:ralmada
Comment Utility
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
0
 
LVL 9

Accepted Solution

by:
valkyrie_nc earned 500 total points
Comment Utility
So long as you have defaults assigned for the input parameters in the stored procedure, you can send in only the params you prefer.  The declaration you have above (Param1 int = 0, Param2 int = 0) is perfect.  If any param is required by the proc, just remove the = [whatever].

hth

valkyrie_nc
0
 
LVL 41

Expert Comment

by:ralmada
Comment Utility
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

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now