Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:48:40+00:00 2026-06-04T11:48:40+00:00

I have a class, which has many New() functions to initiate it with various

  • 0

I have a class, which has many “New()” functions to initiate it with various parameters. I would like to create a New() function that will init the class with no arguments. The problem is there is a “fillData” function which fills the data for the class, and takes in the stored procedure to do the work, but has a stored procedure parameter. I don’t want to create a new fillData function, but would like to use the fillData function with no additional need for a stored procedure. My way of going about this was to pass an empty SqlParameter var to the fillData function, but no mater what I do, when I check the params parameter for being empty, it always seems to think there’s stuff in there.

I would like to check if this “params” parameter is empty:

Public Sub New()
    'just created this so i could pass something
    'and continue using fillData as is.
    Dim p(1) As SqlParameter 

    Dim db As sqldb.command
    db = New sqldb.command(ConfigurationManager.ConnectionStrings("sqlConnectionString").ConnectionString)
    fillData("r2m_getAllListingsSorted", p)
End Sub

…

Private Sub fillData(ByVal sp As String, ByVal params As SqlParameter())
    Dim db As sqldb.command
    Dim r As SqlDataReader
    db = New sqldb.command(ConfigurationManager.ConnectionStrings("sqlConnectionString").ConnectionString)

    'right here, im having the trouble, seems no matter how I try to "params", 
    'the code always defaults to db.executeReader(sp, p)
    'I've tried params.Length = 0 and params.ToString = "" also.
    If params.Value Then
        r = db.executeReader(sp)
    Else
        r = db.executeReader(sp, params)
    End If

How would I modify this so i could continue to use the fillData function, without passing a SqlParameter parameter to it?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:48:42+00:00Added an answer on June 4, 2026 at 11:48 am

    You can make your SqlParameter Optional and give it a default value of Nothing:

    Private Sub fillData(ByVal sp As String, 
                                ByVal Optional params As SqlParameter() = Nothing)
    

    Then call the method without the params argument:

    fillData("StoredProcName")

    You can then check the parameter inside the fillData method to see if it’s Nothing before using it.

    If params is Nothing Then
      // Do something if there's no params
    Else
     // Do something if there is params
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class which has a function to retrieve children elements from a
In my application I have a class which has properties of user-defined types like
I have a class (NamedPipeManager) which has a thread (PipeThread) that waits for a
Using C++ I built a Class that has many setter functions, as well as
I have a class which has a private attribute which is a reference to
I have a class which has a private attribute vector rectVec; class A {
I have a class which has two HashSet<String> collections as private members. Other classes
I have a class which has functionality to initialise opengl and run it in
I have a class which has a variety of details, as follows: Vehicle Name
I have a class which has implemented INotifyPropertyChanged . This class UserInfo has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.