Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Major mixup in two ASP.NET transactions
Message
From
25/09/2006 17:16:38
 
 
To
25/09/2006 11:40:52
Keith Payne
Technical Marketing Solutions
Florida, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01150471
Message ID:
01157105
Views:
49
>I was thinking of writing to the system event log inside of the Dispose method of your provider class. To do it you will have to override the Dispose method in the class definition. The date & time is already part of the log, so anything that can identify the individual instance of your class and also connection.State is sufficient for the log entry. Then you can see exactly when the objects that are connected to the database are destroyed. Maybe there is a correlation between objects remaining open and the errors that you are seeing.

This is what I have presently for the SQLExec() method which is part of the data class I am using from my framework. I do not issue any oConnection.Dispose(). I only use oConnection.Close(), in case it would be required. Do you think I should force a oConnection.Dispose() when the SQL is completed?
        ' SQL exec
        ' expC1 SQL command
        ' expO1 Connection
        Public Function SQLExec(ByVal tcSQL As String, ByVal tcConnection As String) As Boolean
            Dim lcCommandText As String = ""
            Dim llSuccess As Boolean = False

            ' If no connection string
            If tcConnection.Length = 0 Then

                ' Get the proper definition as per the current scope
                If oProcess Is Nothing Then
                    oApp.ErrorSetupControlledByTheFramework("Framework.Data.SQLExec() The connection string is empty. " + tcSQL, _
                     "Data")
                Else
                    oProcess.ErrorSetupControlledByTheFramework("Framework.Data.SQLExec() The connection string is empty. " + tcSQL, _
                     "Data")
                End If

                Return False
            End If

            InitializeDataObject(tcConnection, tcSQL)
            Try
                oCommand.Connection = oConnection

                ' Add all command text
                If oCommandText.Count > 0 Then
                    oCommand.Connection.Open()
                    For Each lcCommandText In oCommandText
                        oCommand.CommandText = lcCommandText
                        oCommand.ExecuteNonQuery()
                    Next
                End If

                oCommand.CommandText = tcSQL

                ' Only add the parameters if we have some
                oCommand.Parameters.Clear()
                If Not oParameters2 Is Nothing Then
                    For Each oDataParameter In oParameters2
                        oCommand.Parameters.Add(oDataParameter)
                    Next
                End If

                oDataAdapter.SelectCommand = oCommand
                oDataSet = New DataSet

                ' By default, .NET does not add the specific field length, which is needed in XML as at the other end
                ' someone would always get memo field instead of character field
                oDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

                oDataAdapter.Fill(oDataSet)

                ' If we have a command text
                If oCommandText.Count > 0 Then
                    oCommand.Connection.Close()

                    ' Clear the command text collection
                    oCommandText.Clear()

                End If

                ' Adjust to our default name
                oDataSet.Tables("Table").TableName = "Temp"

                ' Record count
                nCount = oDataSet.Tables("Temp").Rows.Count

                ' If we have at least one record
                If nCount > 0 Then
                    oDataView = New DataView
                    oDataView = oDataSet.Tables("Temp").DefaultView
                End If

                ' Clear the parameter collection
                If oParameters2.Count > 0 Then
                    oParameters.Clear()
                    oParameters2.Clear()
                    oCommand.Parameters.Clear()
                End If

                llSuccess = True
            Catch loError As Exception
                oConnection.Close()

                ' Get the proper definition as per the current scope
                If oProcess Is Nothing Then
                    oApp.ErrorSetup(loError, oApp.Debug(cSQL + ErrorDetail()))
                Else
                    oProcess.ErrorSetup(loError, oApp.Debug(cSQL + ErrorDetail()))
                End If

            End Try
            Return llSuccess
        End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform