oleDbConnection.open problem

  • Thread starter Thread starter juicy
  • Start date Start date
J

juicy

I need to call oleDbConnection.open concurrently in several class or in the same class
but there is an exception
System.InvalidOperationException occurred in system.data.dll
Additional information: The connection is already open (state=open)


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
Juicy,

In an application you can only use one open connection in a time in Net 1.x

Solution, just do it as recomended create and dispose it every time that it
is needed.
(Although this is a recommendation for when there are simultane more than
100 connections)

I hope this helps?

Cor
 
Hey Juicy,

Another way around this is to declare a public connection, maybe creating a
seperate DB class for your database connection handling. Then make sure that
all forms and classes are using your: newdbclass.connDB. The disadvantage to
this is not being able to use the visual designer to set the connection
property of dbcommands. you must do this manually in code.

Typically I do it this way to ensure there is only one instance of the
connection and the state is definate. Other benefits also include a way of
getting the connection statechange event for the entire application. This
comes in handy for statusbars. as you know that when the status changes in
this public connection there is something happening.

Regards,

Michael Proctor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top