PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Connection closes arbitrarily

Reply

Connection closes arbitrarily

 
Thread Tools Rate Thread
Old 23-03-2005, 03:18 AM   #1
Kieran
Guest
 
Posts: n/a
Default Connection closes arbitrarily


I have a problem with a connection arbitrarily closing within my
method. The connection and transaction are created outside this method
and several other methods use these prior to this method being called.
The connection usually (but not always) persists sufficiently long
within this method for a local connection not to be created. The same
problem occurs whether I run right through or debug the code. The
connection usually closes while populating the data row and an
exception is then thrown outside of this method when attempting to
commit the transaction.

Additional information: An error occured while processing new Dummy
requests:This SqlTransaction has completed; it is no longer usable.

On occasions where a local connection is created, an exception is
thrown when attempting to insert the row since a newly inserted row to
another table to which this row has a foreign key is lost from the
transaction.

I am using mutexes so that other processes should not run while this
code is being handled - however, taking the mutex wrapper out from
around the call to this process makes no difference on the outcome.
Any ideas?

Dim blnLocalConnection As Boolean = False
Dim blnLocalTransaction As Boolean = False

Try
If Me.Connection.State = ConnectionState.Closed Then
Me.Connection.Open()
blnLocalConnection = True
End If

If Me.Transaction Is Nothing Then
Me.Transaction =
Me.Connection.BeginTransaction(IsolationLevel.RepeatableRead)
blnLocalTransaction = True
End If

' Instantiate a new DummyActivateGSMSP31Request object to
process the DummyActivateGSMSP31Request details
' Dim objDummyActivateGSMSP31Request As New
DummyActivateGSMSP31Request(Me.Connection, Me.Transaction)

' Instantiate a new DummyActivateGSMSP31Request datAset to
hold the DummyActivateGSMSP31Request detail rows
Dim dstDummyActivateGSMSP31Request As New
DummyActivateGSMSP31RequestDataset

' Instantiate a DummyActivateGSMSP31RequestRow to hold the
DummyActivateGSMSP31Request details
Dim rowDummyActivateGSMSP31Request As
DummyActivateGSMSP31RequestDataset.DummyActivateGSMSP31RequestRow =
dstDummyActivateGSMSP31Request.DummyActivateGSMSP31Request.NewDummyActivateGSMSP31RequestRow()

' Set the row values
rowDummyActivateGSMSP31Request.DummyContext =
ActivateGSMRequest.DummyContext
rowDummyActivateGSMSP31Request.PhoneNo =
ActivateGSMRequest.PhoneNo
rowDummyActivateGSMSP31Request.AccountNumber =
ActivateGSMRequest.AccountNumber
..
..
..

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off