From: Richard B. <rb...@us...> - 2005-02-07 07:38:07
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_MySQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10604/Providers/AF_MySQL Added Files: AF_MySQL.vbproj AssemblyInfo.vb CMySQLConnection.vb CMySqlDatabase.vb Log Message: Break out providers to separate .DLL files. Change <database /> mapping to use proider="xx" instead of class="xx" Start prep work for Informix provider --- NEW FILE: AssemblyInfo.vb --- Imports System Imports System.Reflection Imports System.Runtime.InteropServices ' General Information about an assembly is controlled through the following ' set of attributes. Change these attribute values to modify the information ' associated with an assembly. ' Review the values of the assembly attributes <Assembly: AssemblyTitle("")> <Assembly: AssemblyDescription("")> <Assembly: AssemblyCompany("")> <Assembly: AssemblyProduct("")> <Assembly: AssemblyCopyright("")> <Assembly: AssemblyTrademark("")> <Assembly: CLSCompliant(True)> 'The following GUID is for the ID of the typelib if this project is exposed to COM <Assembly: Guid("01A0B977-9E65-4337-8ADB-CD71D6A5ED5F")> ' Version information for an assembly consists of the following four values: ' ' Major Version ' Minor Version ' Build Number ' Revision ' ' You can specify all the values or you can default the Build and Revision Numbers ' by using the '*' as shown below: <Assembly: AssemblyVersion("1.0.*")> --- NEW FILE: CMySqlDatabase.vb --- Option Strict Off Option Explicit On 'Imports System.Data.OleDb Imports ByteFX.Data.MySqlClient Imports AToMSFramework '''----------------------------------------------------------------------------- ''' Project : AToMSFramework ''' Class : CMySqlDatabase ''' '''----------------------------------------------------------------------------- ''' <summary> ''' Implementation of CRelationalDatabase for MySQL Servers. ''' </summary> ''' <remarks>This class contains the specific functionality required for the ''' framework to interact with MySQL databases. ADO.NET functionality is provided ''' through the ByteFX provider libraries available at <see href="http://www.bytefx.com">Byte FX</see>. ''' <para>The transaction handling version of MySQL should be used (ie mySql-max or similar).</para></remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Class CMySqlDatabase Inherits CRelationalDatabase '************************************************** 'Class: CMySqlDatabase 'Author: Juan Carlos Alvarez '************************************************** Private m_name As String Private m_user As String Private m_password As String Private m_serverName As String Private m_portNumber As String Private m_option As String '''----------------------------------------------------------------------------- ''' <summary> ''' Establishes a new database connection. ''' </summary> ''' <returns>A CMySqlConnection containing the newly established connection.</returns> ''' <remarks>The CMySqlConnection class implements the _CConnection interface which ''' is required by this method. ''' <para>If the connection cannot be established an exception will be thrown.</para> ''' </remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getNewConnection() As _CConnection Dim conn As New CMySqlConnection conn.Connection = New MySqlConnection 'MySql can manage transactions in if the mysql-max version is used. conn.ManageTransactions = True 'If you have the server on a local machine: 'The values (parameters defined in the xml file) are: 'option = 16834 'If you have the server on a remote machine 'The values (parameters defined in the xml file) are: 'option = 131072 If m_user Is Nothing OrElse m_user.Length = 0 Then m_user = "" m_password = "" Dim pbroker As CPersistenceBroker pbroker = getPersistenceBrokerInstance() pbroker.GetLoginDetails(Me, m_user, m_password) End If If m_user Is Nothing OrElse m_user.Length = 0 Then conn.Connection.ConnectionString = "Server=" & m_serverName & ";" & "Database=" & m_name & ";" Else conn.Connection.ConnectionString = "Server=" & m_serverName & ";" & "Database=" & m_name & ";" & "User ID=" & m_user & ";" & "Password=" & m_password End If conn.Connection.Open() 'If you have the server on a remote machine 'portNumber is by default 3306 'server for example is mydb.database.com 'conn.Connection.Open "Driver={mySQL};" & _ '"Server=" & m_serverName & ";" & _ '"Port=" & m_portNumber & ";" & _ '"Option=131072;" & _ '"Stmt=;" & _ '"Database=" & m_name & ";" & _ '"User Id=" & m_user & ";" & _ '"Password=" & m_password getNewConnection = conn End Function '''----------------------------------------------------------------------------- ''' <summary> ''' Sets the initial properties of the database. ''' </summary> ''' <param name="properties">The property information supplied in the XML mapping file.</param> ''' <remarks>In order to initialise the database object properly the following must be supplied ''' <list type="bullet"> ''' <item><description>Name: The name of the database on the server (ie the catalog name)</description></item> ''' <item><description>ServerName: The name of the database server</description></item> ''' <item><description>User: The user name for secured databases.</description></item> ''' <item><description>Password: The password for secured databases.</description></item> ''' <item><description>PortNumber: (optional - unused) The port number the database is running on.</description></item> ''' <item><description>Option: (optional - unused) Other options to pass in the connection string.</description></item> ''' <item><description>OIDTable: The table name containing the OID A-value. Can be ignored if OIDs are not used.</description></item> ''' </list> ''' <para>If the database is used without having been properly initialised you are likely ''' to get exceptions thrown in your application.</para> ''' </remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Sub init(ByVal properties As System.Collections.Specialized.HybridDictionary) m_name = properties.Item("name") m_serverName = properties.Item("serverName") m_user = properties.Item("user") m_password = properties.Item("password") m_portNumber = properties.Item("portNumber") m_option = properties.Item("option") If properties.Item("ansinulls") Is Nothing Then UseANSINulls = False Else UseANSINulls = properties.Item("ansinulls") End If MyBase.OIDTable = properties.Item("OIDTable") End Sub '''----------------------------------------------------------------------------- ''' <summary> ''' Gets the value of an object in a format the database can understand. ''' </summary> ''' <param name="tempValue">The object being evaluated.</param> ''' <returns>A string containing the SQL compatible value for the object</returns> ''' <remarks>The following rules are applied when converting object values into ''' database compatible strings ''' <para>Any value that is a Null Alias <see cref="M:AToMSFramework.ModAliasNull.IsNullAlias"/> ''' will be returned as NULL.</para> ''' <para>Strings are enclosed in single quotes. If the string is already enclosed in single quotes then ''' nothing is changed. Also, any single quotes within the string are converted to a pair of single quotes.</para> ''' <para>Dates are converted to yyyy-MM-dd HH:mm:ss format and enclosed in single quotes. If a datetime field ''' only has a time value, then a time-only string is returned instead.</para> ''' <para>Booleans are converted to 1 or 0</para> ''' <para>Numbers are converted to strings directly. Note that floating point numbers from locales that use ''' a comma for the decimal marker are converted to use the period as the decimal marker.</para> ''' <para>Objects that are nothing return a NULL and all other objects are directly converted to strings using their ''' inbuilt ToString methods.</para></remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getValueFor(ByVal tempValue As Object) As String Dim tempRetorno As String Dim dd As DateTime Dim OriginalCulture As System.Globalization.CultureInfo Dim TempCulture As System.Globalization.CultureInfo If IsNullAlias(tempValue) Then tempRetorno = "NULL" Else Select Case VarType(tempValue) Case VariantType.String If Left(tempValue, 1) = "'" And Right(tempValue, 1) = "'" And CStr(tempValue).Length > 2 Then 'string already enclosed in quotes so ignore tempRetorno = tempValue Else 'replace single quote with double quote, and enclose entire string in quotes tempRetorno = "'" & Replace(tempValue, "'", "''") & "'" End If Case VariantType.Date TempCulture = New System.Globalization.CultureInfo("en-US") OriginalCulture = System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = TempCulture System.Threading.Thread.CurrentThread.CurrentUICulture = TempCulture dd = CType(tempValue, DateTime) If dd = Date.MinValue Then tempRetorno = "NULL" Else tempRetorno = "'" & dd.ToString("yyyy-MM-dd HH:mm:ss") & "'" End If System.Threading.Thread.CurrentThread.CurrentCulture = OriginalCulture System.Threading.Thread.CurrentThread.CurrentUICulture = OriginalCulture Case VariantType.Boolean 'tempRetorno = IIf(tempValue, "TRUE", "FALSE") tempRetorno = IIf(tempValue, "1", "0") Case VariantType.Single, VariantType.Double, VariantType.Decimal, VariantType.Decimal tempRetorno = Replace(tempValue, ",", ".") Case Else tempRetorno = tempValue End Select End If getValueFor = tempRetorno End Function '''----------------------------------------------------------------------------- ''' <summary> ''' Gets the next OID A-Value from the database. ''' </summary> ''' <returns>A integer containing the A-Value.</returns> ''' <remarks>A connection is established to the database and the OIDTable (specified in ''' the XML mapping) is queried and updated. The obtained A-Value is returned. ''' <para>Should an error occur a value of 0 will be returned.</para></remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getNextOIDAvalue() As Integer Dim rs As New DataSet Dim da As New MySqlDataAdapter Dim cb As MySqlCommandBuilder Dim aValue As Integer Dim row As System.Data.DataRow Dim p As MySqlParameter Dim initvals() As Object = {1} Dim x As OIDException Dim conn As CMySqlConnection conn = Me.getConnection(Nothing) conn.AutoCommit = False conn.startTransaction() Try da.SelectCommand = New MySqlCommand("select oidAValue from " & Me.OIDTable, conn.Connection, conn.Transaction) cb = New MySqlCommandBuilder(da) da.Fill(rs, "oid") If rs.Tables(0).Rows.Count = 0 Then 'Seed with value = 1 row = rs.Tables(0).Rows.Add(initvals) aValue = 1 Else rs.Tables(0).Rows(0).Item(0) += 1 aValue = rs.Tables(0).Rows(0).Item(0) End If da.Update(rs, "oid") da.Dispose() conn.commit() Catch err As MySqlException 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 '''----------------------------------------------------------------------------- ''' <summary> ''' Method to get the last Identity value for the connection. ''' </summary> ''' <param name="conn">The connection to use.</param> ''' <returns>An integer containing the value of the last updated identity column</returns> ''' <remarks>If multiple identity columns were updated the return value will only contain ''' the value of the last identity column updated. ''' <para>Identity values are retrieved by querying LAST_INSERT_ID.</para> ''' <para>Should an error occur an exception will be thrown.</para></remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getIdentityValue(ByVal conn As _CConnection) As Integer Dim rs As New DataSet Dim da As New MySqlDataAdapter Dim cb As MySqlCommandBuilder Dim aValue As Integer Dim connection As CMySqlConnection connection = conn connection.AutoCommit = False Try da.SelectCommand = New MySqlCommand("select LAST_INSERT_ID()", connection.Connection, connection.Transaction) cb = New MySqlCommandBuilder(da) da.Fill(rs, "identity") If rs.Tables(0).Rows.Count = 0 Then Throw New IdentityValueException("Could not retrieve identity value") Else If IsDBNull(rs.Tables(0).Rows(0).Item(0)) Then aValue = 0 Else aValue = rs.Tables(0).Rows(0).Item(0) End If Debug.WriteLine("Returned Identity value: " & aValue.ToString) End If da.Dispose() Catch err As MySqlException Throw New IdentityValueException(err.Message, err) End Try Return aValue End Function '''----------------------------------------------------------------------------- ''' <summary> ''' Returns the SQL syntax placeholder for a parameter ''' </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 a MySQL connection only a single ''' question mark (?) is returned. (This required validation)</remarks> ''' <history> ''' [rbanks] 23/01/2004 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getParamHolder(ByVal i As Integer) As String 'Return "?" Return "@p" & CStr(i) End Function Public Overrides Function getClauseStringTableAlias(ByVal table As String, ByVal owner As String, ByVal pAlias As String) As String Return Me.m_name & "." & table & " as " & pAlias End Function Public Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If Not m_disposed Then If disposing Then Dim conn As CMySqlConnection While ConnectionPool.Count > 0 conn = ConnectionPool.Pop conn.Dispose() End While m_disposed = True End If End If End Sub Public Overrides Function supportsSelectOffsets() As Boolean Return True End Function End Class --- NEW FILE: CMySQLConnection.vb --- Imports ByteFX.Data.MySqlClient Imports AToMSFramework '''----------------------------------------------------------------------------- ''' Project : AToMSFramework ''' Class : CMySqlConnection ''' '''----------------------------------------------------------------------------- ''' <summary> ''' Connection class for MySQL data sources (MySQL 4.0 or higher) ''' </summary> ''' <remarks><para>This class implements the <see cref="T:AToMSFramework._CConnection"/> interface and is used ''' to manage connections to MySQL datasources.</para> ''' <para>The following should be taken into consideration when using this ''' class:</para> ''' <para>1. Only one physical transaction runs on a database connection at any one time</para> ''' <para>2. Only one physical connection to the database exists. Multiple connection ''' objects will share a connection where possible</para> ''' <para>3. If nested transactions are started, the commit or rollback only occurs on the ''' first transaction created. A rollback on any nested transaction will cause all ''' outside transactions to also roll back.</para> ''' </remarks> ''' <seealso cref="T:AToMSFramework._CConnection"/> ''' <history> ''' [rbanks] 18/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Class CMySqlConnection Implements _CConnection Implements IDisposable '************************************************** 'Class: CMySqlConnection 'Author: Richard Banks '************************************************** Private m_connection As MySqlConnection Private m_autoCommit As Boolean Private m_started As Boolean Private m_manageTransactions As Boolean Private m_transaction As MySqlTransaction Private m_transactioncalls As Integer Private m_references As Integer Private m_db As _CRelationalDatabase Private Const DEBUG_MODE As Boolean = True Private m_disposed As Boolean '''----------------------------------------------------------------------------- ''' <summary> ''' The actual MySQL connection for the object. ''' </summary> ''' <value></value> ''' <remarks></remarks> ''' <history> ''' [rbanks] 1/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Property Connection() As MySqlConnection Get Connection = m_connection End Get Set(ByVal Value As MySqlConnection) 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.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="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 on the MySQL connection. ''' </summary> ''' <value></value> ''' <remarks>The MySQL database must support transactions is this is to be non-null.</remarks> ''' <history> ''' [rbanks] 1/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public ReadOnly Property Transaction() As MySqlTransaction Get Transaction = m_transaction End Get End Property '''----------------------------------------------------------------------------- ''' <summary> ''' See <see cref="M:AToMSFramework._CConnection.startTransaction">_CConnection</see>. ''' </summary> ''' <remarks>The mySQL database must support transactions for this to function properly. ''' If the database does not support transactions results may be unpredictable.</remarks> ''' <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> ''' <remarks>The mySQL database must support transactions for this to function properly. ''' If the database does not support transactions results may be unpredictable.</remarks> ''' <history> ''' [rbanks] 1/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overloads Sub startTransaction(ByVal isolationLevel As 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 '''----------------------------------------------------------------------------- ''' <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 MySqlCommand Dim m_recordcount As Integer Dim cp As CSQLParameter Dim param As MySqlParameter Try ' Me.startTransaction() Debug.WriteLine(statement.SqlString) m_command.Connection = m_connection m_command.CommandText = statement.SqlString For Each cp In statement.Parameters If Not cp.Ignore Then param = New MySqlParameter param.ParameterName = cp.Name param.MySqlDbType = CType(cp.Column.ProviderType, MySqlDbType) param.Value = cp.Value m_command.Parameters.Add(param) End If Next m_command.Transaction = m_transaction m_recordcount = m_command.ExecuteNonQuery() If m_recordcount = 0 Then Throw New NothingUpdatedException("No records were affected") End If Catch err As MySqlException 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(CMySqlConnection) Dim x As RetrieveException Dim rs As New CResultset Dim m_command As New MySqlCommand Dim cp As CSQLParameter Dim param As MySqlParameter 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 In statement.Parameters If Not cp.Ignore Then param = New MySqlParameter param.ParameterName = cp.Name param.MySqlDbType = CType(cp.Column.ProviderType, MySqlDbType) param.Value = cp.Value m_command.Parameters.Add(param) End If Next Try Dim m_adapter As New MySqlDataAdapter(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 MySqlException x = New RetrieveException("MySQL 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 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 Public Sub New() MyBase.New() 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="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.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 MySqlCommand Dim dr As MySqlDataReader Dim dt As DataTable statement = "select * from " & tName Try cmd = New MySqlCommand(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 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 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.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 End Class --- NEW FILE: AF_MySQL.vbproj --- <VisualStudioProject> <VisualBasic ProjectType = "Local" ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{0421A413-1FDE-452E-AB47-82E2CD959461}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "AF_MySQL" AssemblyOriginatorKeyFile = "" AssemblyOriginatorKeyMode = "None" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" OptionCompare = "Binary" OptionExplicit = "On" OptionStrict = "Off" RootNamespace = "AF_MySQL" StartupObject = "" > <Config Name = "Debug" BaseAddress = "285212672" ConfigurationOverrideFile = "" DefineConstants = "" DefineDebug = "true" DefineTrace = "true" DebugSymbols = "true" IncrementalBuild = "true" Optimize = "false" OutputPath = "bin\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "1" /> <Config Name = "Release" BaseAddress = "285212672" ConfigurationOverrideFile = "" DefineConstants = "" DefineDebug = "false" DefineTrace = "true" DebugSymbols = "false" IncrementalBuild = "false" Optimize = "true" OutputPath = "bin\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "1" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" /> <Reference Name = "System.Data" AssemblyName = "System.Data" /> <Reference Name = "System.XML" AssemblyName = "System.Xml" /> <Reference Name = "ByteFX.MySqlClient" AssemblyName = "ByteFX.MySqlClient" HintPath = "..\..\ByteFX.MySqlClient.dll" /> <Reference Name = "AToMSFramework" Project = "{8FFD05CF-E733-4D8E-BC0E-D9DD37B87384}" Package = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}" /> </References> <Imports> <Import Namespace = "Microsoft.VisualBasic" /> <Import Namespace = "System" /> <Import Namespace = "System.Collections" /> <Import Namespace = "System.Data" /> <Import Namespace = "System.Diagnostics" /> </Imports> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.vb" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "CMySQLConnection.vb" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "CMySqlDatabase.vb" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </VisualBasic> </VisualStudioProject> |