|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
The type initializer threw an exception.error The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. Tried to find on google and no sucess... please help... thanks Private Sub OpenConnection() If _connection Is Nothing Then _connection = New OleDb.OleDbConnection(_connStr) _connection.Open() Else If _connection.State = ConnectionState.Open Then Else _connection.Open()<------- ERRROR HERE End If End If End Sub What makes you think that if the State is not ConnectionState.Open the
connection is closed? Besides Open there are Connecting, Executing, Fetching or Broken. You should really test for Connection.Closed instead. -- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "JohnZing" <john.z***@gmail.com> wrote in message news:1147288777.865177.16910@j33g2000cwa.googlegroups.com... > When i try to open an OleDb connection (access) VS throws the following > error > > The type initializer for > 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. > > Tried to find on google and no sucess... please help... thanks > > Private Sub OpenConnection() > If _connection Is Nothing Then > _connection = New OleDb.OleDbConnection(_connStr) > _connection.Open() > Else > If _connection.State = ConnectionState.Open Then > Else > _connection.Open()<------- ERRROR HERE > End If > End If > End Sub > Ops, I realized that Executing, Fetching and Broken are reserved for future
versions. Anyway, why do you need to "open" an already opened connection? Are you nesting operations? -- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "Miha Markic [MVP C#]" <miha at rthand com> wrote in message news:%23%23EOAxNdGHA.4932@TK2MSFTNGP03.phx.gbl... > What makes you think that if the State is not ConnectionState.Open the > connection is closed? > Besides Open there are Connecting, Executing, Fetching or Broken. > You should really test for Connection.Closed instead. > > -- > Miha Markic [MVP C#] > RightHand .NET consulting & development www.rthand.com > Blog: http://cs.rthand.com/blogs/blog_with_righthand/ > > "JohnZing" <john.z***@gmail.com> wrote in message > news:1147288777.865177.16910@j33g2000cwa.googlegroups.com... >> When i try to open an OleDb connection (access) VS throws the following >> error >> >> The type initializer for >> 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. >> >> Tried to find on google and no sucess... please help... thanks >> >> Private Sub OpenConnection() >> If _connection Is Nothing Then >> _connection = New OleDb.OleDbConnection(_connStr) >> _connection.Open() >> Else >> If _connection.State = ConnectionState.Open Then >> Else >> _connection.Open()<------- ERRROR HERE >> End If >> End If >> End Sub >> > > |
|||||||||||||||||||||||