ADO.NET and Connection Reuse ...

Im using Visual Studio 2003 .NET and ADO.NET to connect to an Oracle 10g database.  Im making use of the Oracle .NET provider.  I will be making several calls to the same Oracle dbase so figured I should leave "open" the connection to make all subsequent query requests.  One thing I';ve been strugling with in .NET is .ExecuteRead() requests failing due to "connection is already open".  Normally i have to close the current connection, create a brand new Connection and Command object then make the new SQL query.  This just seems so inefficent and slow.  Is it possible to leave open the connection to make subsequent query calls with little overhead and speed reduction or is it a requirement to create a new connection and object in .NET?

Can u please provide me with a sample C# conenction to the Oracle .NET Provider to achieve this.

Thanks
anistonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
You shouldn't need to create a new connection. Simply calling the Close() method on the connection when you are finished with it should be enough. It will then be closed ready to be reused in a subsequent call.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Arthur_WoodCommented:
a Connection can be opened, used, then closed as many times as required, without needing to destroy the connection, and then create a New one.  Once a Connection has been closed, you can have your code OPEN it again, when it is needed.

AW

0
devsolnsCommented:
I would not leave a connection open to the database.  Most db providers have built in connection pooling so feel free to open/close as often as you need without hurting performance.  I am a SQL Server guy and I know it does pooling without a special connection string (there are strings that let you have custom pooling settings) but I cant say the same for oracle.

Just think if this was an asp.net application you wouldnt be able to leave a connection open if you wanted because its stateless.

-gp
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.