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

The Archive Base Latest Questions

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

I develop a lot in ASP.NET and I know that you can only open

  • 0

I develop a lot in ASP.NET and I know that you can only open one SQLDataReader for each SQLConnection. However, this does not appear to be the case in VB.NET (form application) i.e. I have opened multiple SQLDataReaders for one connection object. Is this allowed in VB.NET?

If there is not an obvious answer to this then I will post some code.

Here is some code:

Public Function CheckActiveReviews()
            Dim objCon As SqlConnection
            Dim objCommand As SqlCommand, objCommand2 As SqlCommand
            Dim objDR As SqlDataReader, objDR2 As SqlDataReader
            Try
                objCon = New SqlConnection("Data Source=TestDatabase;Initial Catalog=TestTable;User ID=TestUser;Password=TestPassword;MultipleActiveResultSets=True")
                objCommand = New SqlCommand
                objCommand.Connection = objCon
                objCommand2 = New SqlCommand
                objCommand2.Connection = objCon
                objCon.Open()
                objCommand.CommandText = "SELECT ID FROM Person WHERE PersonID > 1000"
                objDR = objCommand.ExecuteReader()
                Do While objDR.Read
                    objCommand2.CommandText = "SELECT * FROM Sport WHERE PersonID = @PersonID "
                    objCommand2.Parameters.AddWithValue("@PersonID", objDR("ID"))
                    objDR2 = objCommand2.ExecuteReader
                Loop

            Catch ex As Exception

            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-06-06T21:37:39+00:00Added an answer on June 6, 2026 at 9:37 pm

    You can use multiple data readers if you use MARS – Multiple Active Result Sets – but I wouldn’t advise that unless you really need it.

    Instead, I’d suggest creating a new SqlConnection object each time you need it – use it for as short a period as you can, then dispose of it (use a Using statement to do this for you). The connection pool will take care of the efficiency in terms of reusing “physical” network connections where possible. That way you don’t need to worry about whether the SqlConnection is already open etc – you just always follow the same “create, open, use, dispose” pattern every time.

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

Sidebar

Related Questions

I know ASP.NET C# very well. I make a lot of stuff like surveys
I am trying to develop a comet page using Asp.net. Surfed a lot and
I am ASP.NET MVC to develop my application on web. This app requires a
I develop a web by using ASP.NET MVC2. Creating the cookie in the background.
Hey guys! I'm using ASP.NET MVC to develop an application for a library with
Consider to develop a web control (ASP.NET). What you would really like to do
I wonder that, Ruby programming language is ...(easy/difficult) to learn. I can develop web
I am starting to redesign and develop a site that contains a lot of
I am looking to develop a ipad app that relies on a lot of
I'm currently working on an Intranet application project, using ASP.NET MVC 3. One of

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.