Web Service VB ExecuteNonQuery

Posted on 2012-09-20
Last Modified: 2012-09-21
In my web service I have a function which executes a stored procedure which needs only one paramater

This is (partial) code
Dim db As Database = DatabaseFactory.CreateDatabase("LocalSqlServer")

 'call stored proc
db.ExecuteNonQuery("usp_NotificationReceiptsEdit", qString)

I need to build another one function that executes a stored procedure which has from 0 to x paramaters

What I'm actually trying to execute is
usp_NotificationReceiptsEdit @encryptedID = 'EBGj5WlSENxIO1LIPIUGPIUGIUGIPI/4de'
Question by:lrbrister
    LVL 25

    Expert Comment

    by:Luis Pérez
    Please, can you explain your problem better? In SQL Server, a stored procedure cannot have a variable number of parameters. Do you mean that you don't know the exact number of parameters of the stored procedure you need to call?

    Author Comment


    Well...I don't need to feed every paramater because I have them set to null...
    I'm wondering how to execute that nonquery

    -- =======================================================
    ALTER PROCEDURE [dbo].[usp_NotificationReceiptsEdit] (
    		@NotificationID     INT = NULL
    		,@DefinitionID      INT = NULL
    		,@RefID                 INT = NULL
    		,@hLinkString      VARCHAR(1000) = NULL 
    		,@encString          VARCHAR(1000) = NULL 
    		,@visitDate            DATETIME = NULL 
    		,@createdBy          VARCHAR(50)   = NULL
    		,@cancelled            BIT	 = NULL)

    Open in new window

    LVL 25

    Accepted Solution

    Well, you can call to ExecuteNonQuery passing a variable number of parameters:
    db.ExecuteNonQuery("usp_NotificationReceiptsEdit", qString, anotherParam, anotherOne...)

    Hope that helps.

    Author Closing Comment

    That was it...thanks.  Just not familiar with the syntax

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now