From: Richard B. <rb...@us...> - 2005-04-01 00:05:15
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_Informix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_Informix Modified Files: CInformixConnection.vb CInformixDatabase.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: CInformixDatabase.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_Informix/CInformixDatabase.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CInformixDatabase.vb 7 Feb 2005 13:22:06 -0000 1.2 +++ CInformixDatabase.vb 1 Apr 2005 00:04:32 -0000 1.3 @@ -24,15 +24,15 @@ Private m_user As String Private m_password As String Private m_serverName As String - Private m_host As String - Private m_service As String + Private m_host As String + Private m_service As String '''----------------------------------------------------------------------------- ''' <summary> ''' Establishes a new database connection. ''' </summary> - ''' <returns>A CInformixConnection containing the newly established connection.</returns> - ''' <remarks>The CInformixConnection class implements the _CConnection interface which + ''' <returns>A CInformixConnection containing the newly established connection.</returns> + ''' <remarks>The CInformixConnection class implements the _CConnection interface which ''' is required by this method. ''' <para>If the connection cannot be established an exception will be thrown.</para> ''' <para>The connection is established using normal SQL server authentication (ie @@ -43,7 +43,7 @@ '''----------------------------------------------------------------------------- Public Overrides Function getNewConnection() As _CConnection Dim conn As New CInformixConnection - conn.Connection = New IfxConnection + conn.Connection = New IfxConnection conn.ManageTransactions = True Try If m_user Is Nothing OrElse m_user.Length = 0 Then @@ -52,23 +52,23 @@ Dim pbroker As CPersistenceBroker pbroker = getPersistenceBrokerInstance() pbroker.GetLoginDetails(Me, m_user, m_password) - End If - If m_service = String.Empty Then m_service = "8080" - conn.Connection.ConnectionString = _ - "Server=" & m_serverName & ";" & _ - "Database=" & m_name & ";" & _ - "Host=" & m_host & ";" & _ - "Protocol=onsoctcp;" & _ - "Service=" & m_service & ";" & _ - "uid=" & m_user & ";" & _ - "Password=" & m_password - conn.Connection.Open() - Catch ex As IfxException - Throw New DatabaseConnectionException(ex.Message, ex) - Catch ex As Exception - Throw New DatabaseConnectionException(ex.Message, ex) - End Try - getNewConnection = conn + End If + If m_service = String.Empty Then m_service = "8080" + conn.Connection.ConnectionString = _ + "Server=" & m_serverName & ";" & _ + "Database=" & m_name & ";" & _ + "Host=" & m_host & ";" & _ + "Protocol=onsoctcp;" & _ + "Service=" & m_service & ";" & _ + "uid=" & m_user & ";" & _ + "Password=" & m_password + conn.Connection.Open() + Catch ex As IfxException + Throw New DatabaseConnectionException(ex.Message, ex) + Catch ex As Exception + Throw New DatabaseConnectionException(ex.Message, ex) + End Try + getNewConnection = conn End Function '''----------------------------------------------------------------------------- @@ -94,9 +94,9 @@ Public Overrides Sub init(ByVal properties As System.Collections.Specialized.HybridDictionary) m_name = properties.Item("name") m_serverName = properties.Item("serverName") - m_host = properties.Item("host") - m_service = properties.Item("service") - m_user = properties.Item("user") + m_host = properties.Item("host") + m_service = properties.Item("service") + m_user = properties.Item("user") m_password = properties.Item("password") If properties.Item("ansinulls") Is Nothing Then UseANSINulls = False @@ -156,11 +156,11 @@ If dd = Date.MinValue Then tempRetorno = "NULL" Else - tempRetorno = "'" & dd.ToString("yyyy-MM-dd HH:mm:ss") & "'" - End If + tempRetorno = "'" & dd.ToString("yyyy-MM-dd HH:mm:ss") & "'" + End If - System.Threading.Thread.CurrentThread.CurrentCulture = OriginalCulture - System.Threading.Thread.CurrentThread.CurrentUICulture = OriginalCulture + System.Threading.Thread.CurrentThread.CurrentCulture = OriginalCulture + System.Threading.Thread.CurrentThread.CurrentUICulture = OriginalCulture Case VariantType.Boolean tempRetorno = IIf(tempValue, "1", "0") Case VariantType.Single, VariantType.Double, VariantType.Decimal, VariantType.Decimal @@ -186,11 +186,11 @@ '''----------------------------------------------------------------------------- Public Overrides Function getNextOIDAvalue() As Integer Dim rs As New DataSet - Dim da As New IfxDataAdapter - Dim cb As IfxCommandBuilder + Dim da As New IfxDataAdapter + Dim cb As IfxCommandBuilder Dim aValue As Integer Dim row As System.Data.DataRow - Dim p As IfxParameter + Dim p As IfxParameter Dim initvals() As Object = {1} Dim x As OIDException Dim conn As CInformixConnection @@ -198,8 +198,8 @@ conn.AutoCommit = False conn.startTransaction() Try - da.SelectCommand = New IfxCommand("select oidAValue from " & Me.OIDTable, conn.Connection, conn.Transaction) - cb = New IfxCommandBuilder(da) + da.SelectCommand = New IfxCommand("select oidAValue from " & Me.OIDTable, conn.Connection, conn.Transaction) + cb = New IfxCommandBuilder(da) da.Fill(rs, "oid") If rs.Tables(0).Rows.Count = 0 Then 'Seed with value = 1 @@ -212,19 +212,19 @@ da.Update(rs, "oid") da.Dispose() conn.commit() - Catch err As IfxException - conn.rollback() - x = New OIDException(err.Message, err) - Catch err As Exception - conn.rollback() - x = New OIDException(err.Message, err) - Finally - Me.freeConnection(conn) - If Not x Is Nothing Then - Throw x - End If - End Try - Return aValue + Catch err As IfxException + conn.rollback() + x = New OIDException(err.Message, err) + Catch err As Exception + conn.rollback() + x = New OIDException(err.Message, err) + Finally + Me.freeConnection(conn) + If Not x Is Nothing Then + Throw x + End If + End Try + Return aValue End Function '''----------------------------------------------------------------------------- @@ -243,8 +243,8 @@ '''----------------------------------------------------------------------------- Public Overrides Function getIdentityValue(ByVal conn As _CConnection) As Integer Dim rs As New DataSet - Dim da As New IfxDataAdapter - Dim cb As IfxCommandBuilder + Dim da As New IfxDataAdapter + Dim cb As IfxCommandBuilder Dim aValue As Integer Dim connection As CInformixConnection @@ -252,8 +252,8 @@ connection.AutoCommit = False Try - da.SelectCommand = New IfxCommand("select @@IDENTITY", connection.Connection, connection.Transaction) - cb = New IfxCommandBuilder(da) + da.SelectCommand = New IfxCommand("select @@IDENTITY", connection.Connection, connection.Transaction) + cb = New IfxCommandBuilder(da) da.Fill(rs, "identity") If rs.Tables(0).Rows.Count = 0 Then Throw New IdentityValueException("Could not retrieve identity value") @@ -266,10 +266,10 @@ Debug.WriteLine("Returned Identity value: " & aValue.ToString) End If da.Dispose() - Catch err As IfxException - Throw New IdentityValueException(err.Message, err) - End Try - Return aValue + Catch err As IfxException + Throw New IdentityValueException(err.Message, err) + End Try + Return aValue End Function '''----------------------------------------------------------------------------- @@ -278,7 +278,7 @@ ''' </summary> ''' <param name="i">The number of the parameter being added</param> ''' <returns>A string containing the SQL parameter placeholder</returns> - ''' <remarks>Since the parameter is for an Informix connection only a the returned + ''' <remarks>Since the parameter is for an Informix connection only a the returned ''' string is in the format of @pxxx where xxx is the value of the input integer (i).</remarks> ''' <history> ''' [rbanks] 23/01/2004 Created Index: CInformixConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_Informix/CInformixConnection.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CInformixConnection.vb 7 Feb 2005 13:22:06 -0000 1.2 +++ CInformixConnection.vb 1 Apr 2005 00:04:31 -0000 1.3 @@ -31,15 +31,15 @@ Implements IDisposable '************************************************** - 'Class: CInformixConnection + 'Class: CInformixConnection 'Author: Richard Banks '************************************************** - Private m_connection As IfxConnection + Private m_connection As IfxConnection Private m_autoCommit As Boolean Private m_started As Boolean Private m_manageTransactions As Boolean - Private m_transaction As IfxTransaction + Private m_transaction As IfxTransaction Private m_transactioncalls As Integer Private m_references As Integer Private m_db As _CRelationalDatabase @@ -48,7 +48,7 @@ '''----------------------------------------------------------------------------- ''' <summary> - ''' The actual Informix Server connection for the object. + ''' The actual Informix Server connection for the object. ''' </summary> ''' <value></value> ''' <remarks></remarks> @@ -56,408 +56,409 @@ ''' [rbanks] 1/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Property Connection() As IfxConnection - Get - Connection = m_connection - End Get - Set(ByVal Value As IfxConnection) - m_connection = Value - End Set - End Property + Public Property Connection() As IfxConnection + Get + Connection = m_connection + End Get + Set(ByVal Value As IfxConnection) + m_connection = Value + End Set + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="P:AToMSFramework._CConnection.AutoCommit">_CConnection</see>. - ''' </summary> - ''' <value></value> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Property AutoCommit() As Boolean Implements _CConnection.AutoCommit - Get - AutoCommit = m_autoCommit - End Get - Set(ByVal Value As Boolean) - m_autoCommit = Value - End Set - End Property + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.AutoCommit">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property AutoCommit() As Boolean Implements _CConnection.AutoCommit + Get + AutoCommit = m_autoCommit + End Get + Set(ByVal Value As Boolean) + m_autoCommit = Value + End Set + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="P:AToMSFramework._CConnection.Started">_CConnection</see>. - ''' </summary> - ''' <value></value> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Property Started() As Boolean Implements _CConnection.Started - Get - Started = m_started - End Get - Set(ByVal Value As Boolean) - m_started = Value - End Set - End Property + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.Started">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property Started() As Boolean Implements _CConnection.Started + Get + Started = m_started + End Get + Set(ByVal Value As Boolean) + m_started = Value + End Set + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="P:AToMSFramework._CConnection.ManageTransactions">_CConnection</see>. - ''' </summary> - ''' <value></value> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Property ManageTransactions() As Boolean Implements _CConnection.ManageTransactions - Get - ManageTransactions = m_manageTransactions - End Get - Set(ByVal Value As Boolean) - m_manageTransactions = Value - End Set - End Property + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.ManageTransactions">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property ManageTransactions() As Boolean Implements _CConnection.ManageTransactions + Get + ManageTransactions = m_manageTransactions + End Get + Set(ByVal Value As Boolean) + m_manageTransactions = Value + End Set + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="M:AToMSFramework._CConnection.commit">_CConnection</see>. - ''' </summary> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub commit() Implements _CConnection.commit - If DEBUG_MODE Then - If m_transactioncalls = 1 Then - System.Diagnostics.Debug.WriteLine("COMMIT TRANSACTION") - Else - System.Diagnostics.Debug.WriteLine("Nested COMMIT TRANSACTION - not actually called") - End If - End If - If Me.ManageTransactions Then - If m_transactioncalls = 1 Then - m_transaction.Commit() - getPersistenceBrokerInstance().commitCache(Me.Database) - Me.Started = False - m_transaction = Nothing - End If - m_transactioncalls -= 1 - End If - End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.commit">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub commit() Implements _CConnection.commit + If DEBUG_MODE Then + If m_transactioncalls = 1 Then + System.Diagnostics.Debug.WriteLine("COMMIT TRANSACTION") + Else + System.Diagnostics.Debug.WriteLine("Nested COMMIT TRANSACTION - not actually called") + End If + End If + If Me.ManageTransactions Then + If m_transactioncalls = 1 Then + m_transaction.Commit() + getPersistenceBrokerInstance().commitCache(Me.Database) + Me.Started = False + m_transaction = Nothing + End If + m_transactioncalls -= 1 + End If + End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' The current transaction for the connection. - ''' </summary> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public ReadOnly Property Transaction() As IfxTransaction - Get - Transaction = m_transaction - End Get - End Property + '''----------------------------------------------------------------------------- + ''' <summary> + ''' The current transaction for the connection. + ''' </summary> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public ReadOnly Property Transaction() As IfxTransaction + Get + Transaction = m_transaction + End Get + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="M:AToMSFramework._CConnection.startTransaction">_CConnection</see>. - ''' </summary> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Overloads Sub startTransaction() Implements _CConnection.startTransaction - If DEBUG_MODE Then - If m_transactioncalls = 0 Then - System.Diagnostics.Debug.WriteLine("BEGIN TRANSACTION") - Else - System.Diagnostics.Debug.WriteLine("Nested BEGIN TRANSACTION - not actually called") - End If - End If - If Me.ManageTransactions Then - If Not Me.Started Then - m_transaction = m_connection.BeginTransaction - getPersistenceBrokerInstance().startCacheTransaction(Me.Database) - End If - m_transactioncalls += 1 - Me.Started = True - End If - End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.startTransaction">_CConnection</see>. + ''' </summary> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Overloads Sub startTransaction() Implements _CConnection.startTransaction + If DEBUG_MODE Then + If m_transactioncalls = 0 Then + System.Diagnostics.Debug.WriteLine("BEGIN TRANSACTION") + Else + System.Diagnostics.Debug.WriteLine("Nested BEGIN TRANSACTION - not actually called") + End If + End If + If Me.ManageTransactions Then + m_transactioncalls += 1 + If Not Me.Started Then + Me.Started = True + m_transaction = m_connection.BeginTransaction + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) + End If + End If + End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="M:AToMSFramework._CConnection.processStatement">_CConnection</see>. - ''' </summary> - ''' <param name="statement"></param> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' [rbanks] 23/01/2004 Changed to use SQL parameters - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub processStatement(ByVal statement As CSqlStatement) Implements _CConnection.processStatement - Dim m_command As New IfxCommand - Dim m_recordcount As Integer - Dim cp As CSQLParameter - Dim param As IfxParameter - Dim dd As Date + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.processStatement">_CConnection</see>. + ''' </summary> + ''' <param name="statement"></param> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' [rbanks] 23/01/2004 Changed to use SQL parameters + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub processStatement(ByVal statement As CSqlStatement) Implements _CConnection.processStatement + Dim m_command As New IfxCommand + Dim m_recordcount As Integer + Dim cp As CSQLParameter + Dim param As IfxParameter + Dim dd As Date - Try - m_command.Connection = m_connection - m_command.CommandText = statement.SqlString - For Each cp In statement.Parameters - If Not cp.Ignore Then - param = New IfxParameter - param.ParameterName = cp.Name - param.IfxType = CType(cp.Column.ProviderType, IfxType) - param.Value = cp.Value - m_command.Parameters.Add(param) - End If - Next - m_command.Transaction = m_transaction - Debug.WriteLine(m_command.CommandText) - m_recordcount = m_command.ExecuteNonQuery() - If m_recordcount = 0 Then - Throw New NothingUpdatedException("No records were affected by the update") - End If - Catch err As IfxException - Throw err - Catch err As Exception - Throw err - End Try - End Sub + Try + m_command.Connection = m_connection + m_command.CommandText = statement.SqlString + For Each cp In statement.Parameters + If Not cp.Ignore Then + param = New IfxParameter + param.ParameterName = cp.Name + param.IfxType = CType(cp.Column.ProviderType, IfxType) + param.Value = cp.Value + m_command.Parameters.Add(param) + End If + Next + m_command.Transaction = m_transaction + Debug.WriteLine(m_command.CommandText) + m_recordcount = m_command.ExecuteNonQuery() + If m_recordcount = 0 Then + Throw New NothingUpdatedException("No records were affected by the update") + End If + Catch err As IfxException + Throw err + Catch err As Exception + Throw err + End Try + End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="M:AToMSFramework._CConnection.processSelectStatement">_CConnection</see>. - ''' </summary> - ''' <param name="statement"></param> - ''' <returns></returns> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Function processSelectStatement(ByVal statement As CSqlStatement) As CResultset Implements _CConnection.processSelectStatement - SyncLock GetType(CInformixConnection) - Dim x As RetrieveException - Dim rs As New CResultset - Dim param As IfxParameter - Dim dd As Date - Dim m_command As New IfxCommand + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.processSelectStatement">_CConnection</see>. + ''' </summary> + ''' <param name="statement"></param> + ''' <returns></returns> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Function processSelectStatement(ByVal statement As CSqlStatement) As CResultset Implements _CConnection.processSelectStatement + SyncLock GetType(CInformixConnection) + Dim x As RetrieveException + Dim rs As New CResultset + Dim param As IfxParameter + Dim dd As Date + Dim m_command As New IfxCommand - If DEBUG_MODE Then - System.Diagnostics.Debug.WriteLine(statement.SqlString) - End If + If DEBUG_MODE Then + System.Diagnostics.Debug.WriteLine(statement.SqlString) + End If - m_command.Connection = m_connection - m_command.CommandText = statement.SqlString - For Each cp As CSQLParameter In statement.Parameters - If Not cp.Ignore Then - param = New IfxParameter - param.ParameterName = cp.Name - param.IfxType = CType(cp.Column.ProviderType, IfxType) - param.Value = cp.Value - m_command.Parameters.Add(param) - End If - Next + m_command.Connection = m_connection + m_command.CommandText = statement.SqlString + For Each cp As CSQLParameter In statement.Parameters + If Not cp.Ignore Then + param = New IfxParameter + param.ParameterName = cp.Name + param.IfxType = CType(cp.Column.ProviderType, IfxType) + param.Value = cp.Value + m_command.Parameters.Add(param) + End If + Next - Try - Dim m_adapter As New IfxDataAdapter(m_command) - If m_transactioncalls > 0 Then m_adapter.SelectCommand.Transaction = m_transaction - m_adapter.Fill(rs.ResultSet, "ole") - m_adapter.Dispose() - Catch err As IfxException - x = New RetrieveException("SQL Error: " & err.Message, err) - Catch err As Exception - x = New RetrieveException(err.Message, err) - End Try - If Not x Is Nothing Then - Throw x - End If - processSelectStatement = rs - End SyncLock - End Function + Try + Dim m_adapter As New IfxDataAdapter(m_command) + If m_transactioncalls > 0 Then m_adapter.SelectCommand.Transaction = m_transaction + m_adapter.Fill(rs.ResultSet, "ole") + m_adapter.Dispose() + Catch err As IfxException + x = New RetrieveException("SQL Error: " & err.Message, err) + Catch err As Exception + x = New RetrieveException(err.Message, err) + End Try + If Not x Is Nothing Then + Throw x + End If + processSelectStatement = rs + End SyncLock + End Function - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="M:AToMSFramework._CConnection.rollback">_CConnection</see>. - ''' </summary> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub rollback() Implements _CConnection.rollback - Dim pb As CPersistenceBroker - If DEBUG_MODE Then - If m_transactioncalls = 1 Then - System.Diagnostics.Debug.WriteLine("ROLLBACK TRANSACTION") - Else - System.Diagnostics.Debug.WriteLine("Nested ROLLBACK TRANSACTION - not actually performed") - End If - End If - If Me.ManageTransactions Then - If m_transactioncalls = 1 Then - Try - m_transaction.Rollback() - Catch ex As Exception - End Try - getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing - End If - m_transactioncalls -= 1 - End If - End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.rollback">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub rollback() Implements _CConnection.rollback + Dim pb As CPersistenceBroker + If DEBUG_MODE Then + If m_transactioncalls = 1 Then + System.Diagnostics.Debug.WriteLine("ROLLBACK TRANSACTION") + Else + System.Diagnostics.Debug.WriteLine("Nested ROLLBACK TRANSACTION - not actually performed") + End If + End If + If Me.ManageTransactions Then + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then + Try + m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing + Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) + End Try + getPersistenceBrokerInstance().rollbackCache(Me.Database) + End If + End If + End Sub - Public Sub New() - MyBase.New() - 'By default we manage tranactions - 'For DB's that do not manage transactions we should - 'set this attribute to false - m_manageTransactions = True - m_references = 0 - End Sub + Public Sub New() + MyBase.New() + 'By default we manage tranactions + 'For DB's that do not manage transactions we should + 'set this attribute to false + m_manageTransactions = True + m_references = 0 + End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="M:AToMSFramework._CConnection.CloseConnection">_CConnection</see>. - ''' </summary> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub CloseConnection() Implements _CConnection.CloseConnection - m_references -= 1 - If m_references = 0 Then - m_connection.Close() - End If - End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.CloseConnection">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub CloseConnection() Implements _CConnection.CloseConnection + m_references -= 1 + If m_references = 0 Then + m_connection.Close() + End If + End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="P:AToMSFramework._CConnection.IsClosed">_CConnection</see>. - ''' </summary> - ''' <value></value> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public ReadOnly Property IsClosed() As Boolean Implements _CConnection.IsClosed - Get - Return m_connection.State = ConnectionState.Closed - End Get - End Property + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.IsClosed">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public ReadOnly Property IsClosed() As Boolean Implements _CConnection.IsClosed + Get + Return m_connection.State = ConnectionState.Closed + End Get + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="P:AToMSFramework._CConnection.ReferenceCount">_CConnection</see>. - ''' </summary> - ''' <value></value> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Property ReferenceCount() As Integer Implements _CConnection.ReferenceCount - Get - Return m_references - End Get - Set(ByVal Value As Integer) - m_references = Value - End Set - End Property + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.ReferenceCount">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property ReferenceCount() As Integer Implements _CConnection.ReferenceCount + Get + Return m_references + End Get + Set(ByVal Value As Integer) + m_references = Value + End Set + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="P:AToMSFramework._CConnection.getTableSchema">_CConnection</see>. - ''' </summary> - ''' <param name="tName"></param> - ''' <returns></returns> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Function getTableSchema(ByVal tName As String) As System.Data.DataTable Implements _CConnection.getTableSchema - Dim statement As String - Dim cmd As IfxCommand - Dim dr As IfxDataReader - Dim dt As DataTable + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.getTableSchema">_CConnection</see>. + ''' </summary> + ''' <param name="tName"></param> + ''' <returns></returns> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Function getTableSchema(ByVal tName As String) As System.Data.DataTable Implements _CConnection.getTableSchema + Dim statement As String + Dim cmd As IfxCommand + Dim dr As IfxDataReader + Dim dt As DataTable - statement = "select * from " & tName - Try - cmd = New IfxCommand(statement, Me.Connection) - dr = cmd.ExecuteReader(CommandBehavior.SchemaOnly) - dt = dr.GetSchemaTable - Catch ex As Exception - dt = Nothing - Throw ex - End Try - Return dt - End Function + statement = "select * from " & tName + Try + cmd = New IfxCommand(statement, Me.Connection) + dr = cmd.ExecuteReader(CommandBehavior.SchemaOnly) + dt = dr.GetSchemaTable + Catch ex As Exception + dt = Nothing + Throw ex + End Try + Return dt + End Function - Public Overloads Sub startTransaction(ByVal isolationLevel As System.Data.IsolationLevel) Implements _CConnection.startTransaction - If DEBUG_MODE Then - If m_transactioncalls = 0 Then - System.Diagnostics.Debug.WriteLine("BEGIN TRANSACTION") - Else - System.Diagnostics.Debug.WriteLine("Nested BEGIN TRANSACTION - not actually called") - End If - End If - If Me.ManageTransactions Then - If Not Me.Started Then - m_transaction = m_connection.BeginTransaction(isolationLevel) - getPersistenceBrokerInstance().startCacheTransaction(Me.Database) - End If - m_transactioncalls += 1 - Me.Started = True - End If - End Sub + Public Overloads Sub startTransaction(ByVal isolationLevel As System.Data.IsolationLevel) Implements _CConnection.startTransaction + If DEBUG_MODE Then + If m_transactioncalls = 0 Then + System.Diagnostics.Debug.WriteLine("BEGIN TRANSACTION") + Else + System.Diagnostics.Debug.WriteLine("Nested BEGIN TRANSACTION - not actually called") + End If + End If + If Me.ManageTransactions Then + m_transactioncalls += 1 + If Not Me.Started Then + Me.Started = True + m_transaction = m_connection.BeginTransaction(isolationLevel) + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) + End If + End If + End Sub - Public Property Database() As _CRelationalDatabase Implements _CConnection.Database - Get - Return m_db - End Get - Set(ByVal Value As _CRelationalDatabase) - m_db = Value - End Set - End Property + Public Property Database() As _CRelationalDatabase Implements _CConnection.Database + Get + Return m_db + End Get + Set(ByVal Value As _CRelationalDatabase) + m_db = Value + End Set + End Property - Public Overloads Sub Dispose() Implements System.IDisposable.Dispose - Dispose(True) - GC.SuppressFinalize(Me) - End Sub + Public Overloads Sub Dispose() Implements System.IDisposable.Dispose + Dispose(True) + GC.SuppressFinalize(Me) + End Sub - Protected Overridable Overloads Sub Dispose(ByVal disposing As Boolean) - If Not m_disposed Then - If disposing Then - If Me.Started AndAlso Not m_transaction Is Nothing Then - m_transaction.Rollback() - m_transaction = Nothing - End If - If Not m_connection Is Nothing Then - m_connection.Close() - m_connection.Dispose() - m_connection = Nothing - End If - m_db = Nothing - m_disposed = True - End If - End If - End Sub + Protected Overridable Overloads Sub Dispose(ByVal disposing As Boolean) + If Not m_disposed Then + If disposing Then + If Me.Started AndAlso Not m_transaction Is Nothing Then + m_transaction.Rollback() + m_transaction = Nothing + End If + If Not m_connection Is Nothing Then + m_connection.Close() + m_connection.Dispose() + m_connection = Nothing + End If + m_db = Nothing + m_disposed = True + End If + End If + End Sub - Protected Overrides Sub Finalize() - ' Simply call Dispose(False). - Dispose(False) - End Sub + Protected Overrides Sub Finalize() + ' Simply call Dispose(False). + Dispose(False) + End Sub End Class |