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 5937651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:34:20+00:00 2026-05-22T15:34:20+00:00

I get this error on the server. I cannot replicate this on my development

  • 0

I get this error on the server. I cannot replicate this on my development machine.

I get it when i call ExecuteReader, ExecuteScalar or when i try to fill a dataset.

I use an oracle database.

This, i think, increases when the load on the server increases. Im not sure.

i need help fixing this. Please let me know if you need anymore details.

The code for ExecuteScalar would be as follows

Public Function ExecuteScalar1(ByVal sExecuteString As String, ByVal sConnectString     As     String) As String
        Dim OrclCmd As New OracleCommand
        Try
            If OpenConnection(sConnectString) Then
                OrclCmd.CommandText = sExecuteString
                OrclCmd.CommandType = CommandType.Text
                OrclCmd.Connection = OrclConn
                ExecuteScalar_ = Convert.ToString(OrclCmd.ExecuteScalar())
                If ExecuteScalar_ Is System.DBNull.Value Then
                    ExecuteScalar_ = ""
                End If

            End If
        Catch ex As Exception
            Err.Raise(Err.Number, Err.Source, Err.Description)
        Finally
            Call CloseConnection()
        End Try
    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-05-22T15:34:21+00:00Added an answer on May 22, 2026 at 3:34 pm

    What does your OpenConnection method do?

    I’m assuming it opens a database connection on a completely independant OracleCommand object. I would suggest the simplest solution here would be to pass your OracleCommand object in ByRef to the OpenConnection method, allowing you to associate a connection and open it within the method.

    Obviously, this will require you to change the OpenConnection method to take both a ConnectionString parameter, as well as an OracleCommand object by reference, the signature would be:

    Public Sub OpenConnection(ByVal sConnectionString As String, ByRef orclCommand As OracleCommand)
    

    This will allow you to work with the OracleCommand object in both methods, with them both referencing the same object – therefore allowing you to call .Open() on the connection, and have the connection open in both methods.

    Re-reading your code…

    You appear to have an object called OrclConn, which you assign to OrclCmd.Connection.

    My psychic debugging tells me this is a Static object declared outside of this Function. If so, there’s your problem – when multiple users are accessing this code, the OrclConn object can have it’s connection closed by another user by the time the command is executed. Typical race condition on a shared object.

    The solution would be to use a connection object local to the function:

    Public Function ExecuteScalar1(ByVal sExecuteString As String, ByVal sConnectString As String) As String
        Dim OrclCmd As New OracleCommand
        Dim OrclConn As New OracleConnection
        Try
            OrclConn.ConnectionString = sConnectString
            OrclConn.Open() 
            'Add any connection initialisation here
    
            OrclCmd.CommandText = sExecuteString
            OrclCmd.CommandType = CommandType.Text
            OrclCmd.Connection = OrclConn
    
            ExecuteScalar_ = Convert.ToString(OrclCmd.ExecuteScalar())
    
            If ExecuteScalar_ Is System.DBNull.Value Then
                ExecuteScalar_ = ""
            End If
        Catch ex As Exception
            Err.Raise(Err.Number, Err.Source, Err.Description)
        Finally
            If OrclConn.State <> ConnectionState.Closed Then ' Can't remember if this is correct
                OrclConn.Close()                             ' Just be sure to call this
            End If
        End Try
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.