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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:54:29+00:00 2026-05-12T16:54:29+00:00

I have 20 different methods and use datareader to read and get result from

  • 0

I have 20 different methods and use datareader to read and get result from these functions in the same event.In top of page I create datareader and then begin to load it step by step(It uses same connection and same data access function).Till 15.function datareader loads without problem but after 15,it loads slowly(record count is about 20-30).When i close datareader after 15.function,this problem doesnt occur.But now after 15.function,i should close datareader if i execute some function.Why does this problem occur,I dont know.I posted sample code here.

'Trying method 1

strSQL.ToString="Select * from A"

dr = DB_Gateway.ReadAndBind(strSQL.ToString)


'Trying method 2

strSQL.ToString="Select * from B"

dr = DB_Gateway.ReadAndBind(strSQL.ToString)

'Trying method 15

strSQL.ToString="Select * from K"

dr = DB_Gateway.ReadAndBind(strSQL.ToString)

AFTER 15. EXECUTION,DATAREADER BEGINS TO LOAD DATA SLOWLY.WHEN I ADD DR.CLOSE AND EXECUTE IT,I DONT HAVE PROBLEM.IF I DONT DO IT,IT LOADS 20 RECORDS WITHING 5 SECONDS.THIS IS MY READANDBIND FUNCTION.I AM CONNECTING ORACLE 11 G.WHAT CAN CAUSE THIS PROBLEM?

Public Shared Function ReadAndBind(ByVal SQL As String) As OracleDataReader 




Dim oraCommand As New OracleCommand 




With oraCommand 

.Connection =


New OracleConnection(CONN_NAME) 

.CommandText = SQL




Dim dtreader As OracleDataReader 




Try

.Connection.Open()

dtreader = .ExecuteReader(CommandBehavior.CloseConnection)



Catch ex As Exception 

Exception_Save(ex.Message, oraCommand.ToString)




Throw



Finally



'.Connection.Close()



'.Connection.Dispose()

oraCommand.Dispose()

oraCommand =

Nothing



End Try



Return dtreader 




End With 






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-12T16:54:29+00:00Added an answer on May 12, 2026 at 4:54 pm

    No, you are not using the same connection for all the commands, you are opening a new connection for each one. As you fail to close them, at the end of the code you will be having 20 database connections open at once.

    Also, you are not using a single data reader, you are creating a new data reader for each query. When you assign the method result to the dr variable it’s not reusing the data reader, it’s throwing away the reference to one reader and replaces it with a new one. It’s normal to use one reader for each result, but it means that you have to close each data reader before getting the next, or you will get an unreachable object that holds on to a database connection until the garbage collector removes it.

    If you close each reader before getting the next, the database connection will be closed and returned to the connection pool so that it can be reused for the next query. Slightly better would be to create a single connection object for the page and use that for each command, that will save a few round trips to the database.

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

Sidebar

Related Questions

I have production (q) values from 4 different methods stored in the 4 matrices.
I've tried two different methods of reusing code. I have a solution full of
I have two DLL files that have the same namespace but they have different
I have a bunch of different methods that are not supposed to run concurrently,
i am autpmating a web site that have different function page. i am making
I have tried two different methods. The first is to specify the link in
I have a static class with number of different methods. I have another class,
different programming languages have different features or lack certain features. Design patterns are a
You can have different naming convention for class members, static objects, global objects, and
Windows Mobile devices have different behaviour for suspending when the device is on battery

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.