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

  • SEARCH
  • Home
  • 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 8171945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:37:27+00:00 2026-06-06T21:37:27+00:00

I am using the following Shared Function to select a value from DB.My concern

  • 0

I am using the following Shared Function to select a value from DB.My concern is that since shared functions are shared among all objects, can this happen that if two persons executes the function almost at a same time, the data will be over written??

I mean the value returned from the DB will be the result of the last (most recent) execution?

EG:

User 1 executes the function and should get “abcd”
User 2 executes the function and should get “1234”

User 2 executes the function before User 1 could complete executing the function.

But both the users get “1234”

Public Shared Function SelectScalar(ByVal _sql As String, ByVal _parameterNames() As String, ByVal _parameterVals() As String) As String
            Dim _returnVal As String
            Dim _connection As SqlConnection = Global.Connection.GetDbConnection()
            Dim _command As New SqlCommand(_sql, _connection)
            Dim _value As String

            Try
                If _parameterNames IsNot Nothing Then
                    For i = 0 To _parameterNames.Length - 1
                        _command.Parameters.AddWithValue(_parameterNames(i), _parameterVals(i))
                    Next
                End If

                _value = CStr(_command.ExecuteScalar)
                _returnVal = _value
            Catch ex As Exception
                _returnVal = Nothing
            Finally
                If _connection.State = ConnectionState.Open Then
                    _connection.Close()
                    _connection.Dispose()
                    _command.Dispose()
                End If
            End Try

            Return _returnVal
        End Function
  • 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-06T21:37:29+00:00Added an answer on June 6, 2026 at 9:37 pm

    Shared Functions does not share their “internal” state, like _returnVal. A separate instance of all local variables are created each time the method is called and each call keeps track of their own set of variables, no cross talking can occur when the variables are declared inside the Shared Function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to call a function from a shared object using ruby-ffi. I
I am trying to run the following C function from Java using JNA, but
I compiled the following code as a shared library using g++ -shared ... :
I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
I have software that first loads a .dylib lets call libFirst.dylib using the following
We have a VB.net function with the following signature in class InitializerFactory: Public Shared
I have the following code: #include <iostream> #include boost/shared_ptr.hpp using boost::shared_ptr; class Base {
I am using the following code for the Share Price Application I have been
Using following code I try to get updated list of checkbuttons' corresponding text values,
I using following code: var search = 'test'; if ($('#sku').find(search) ){ //alert(search); $(document).find(search).css('color','red'); <TABLE>

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.