Imports System Imports System.Data Imports System.Data.OleDb Imports System.IO Namespace DataAccessLayer '------------------------------------------------------------------------------------------------------------------------- ' ' DEVELOPED BY : http://www.visual-basic-data-mining.net/DesktopDefault.aspx ' (http://www.visual-basic-data-mining.net/DesktopDefault.aspx?tabindex=1&tabid=5) ' ' ' ABOUT : VISUAL-BASIC-DATA-MINING.NET DEVELOPS AND DISTRIBUTES DATA MINING ALGORITHMS AND ' SOURCE CODE USING THE .NET FRAMEWORK AND VISUAL BASIC. ' ' GET YOUR OWN FREE DATA MINING SOURCE CODE AND GET FREE DATA MINING WITH .NET SUPPORT FROM THE ' DATA MINING FORUM AT http://www.visual-basic-data-mining.net/Forum ' '------------------------------------------------------------------------------------------------------------------------- Public Class OleDB 'PURPOSE : PROVIDES FUNCTIONS FOR DATABASE ACCESS USING THE SYSTEM.DATA.OLEDB CLASS 'SOURCE : HTTP://WWW.VISUAL-BASIC-DATA-MINING.NET/WEBPAGES/SERVICES.ASPX 'DATE CREATED : OCTOBER 13, 2002, 4:50 PM 'CREATED BY: HTTP://WWW.VISUAL-BASIC-DATA-MINING.NET/DESKTOPDEFAULT.ASPX Private mvarCommandObject As OleDbCommand Private mvarConnectionObject As OleDbConnection Private mvarSQLString As String Private mvarConnectionString As String Private mvarRecordsAffected As Integer Private mvarCommandTimeOut As Integer Public Property ConnectionString() As String Get ConnectionString = mvarConnectionString End Get Set(ByVal Value As String) mvarConnectionString = Value End Set End Property Public Property SQLString() As String Get SQLString = mvarSQLString End Get Set(ByVal Value As String) mvarSQLString = Value End Set End Property Public Property ConnectionObject() As OleDbConnection Get ConnectionObject = mvarConnectionObject End Get Set(ByVal Value As OleDbConnection) mvarConnectionObject = Value End Set End Property Public Property CommandObject() As OleDbCommand Get CommandObject = mvarCommandObject End Get Set(ByVal Value As OleDbCommand) mvarCommandObject = Value End Set End Property Public Property RecordsAffected() As Integer Get RecordsAffected = mvarRecordsAffected End Get Set(ByVal Value As Integer) mvarRecordsAffected = Value End Set End Property Public Property CommandTimeOut() As Integer Get CommandTimeOut = mvarCommandTimeOut End Get Set(ByVal Value As Integer) mvarCommandTimeOut = Value End Set End Property Public Function Execute() As String 'Create a connection to an OleDb database mvarConnectionObject = New OleDbConnection(mvarConnectionString) 'Open the OleDB Database mvarConnectionObject.Open() 'Create a command object which will be used to execute SQL statements mvarCommandObject = New OleDbCommand() 'The type of command that will be executed is a text command mvarCommandObject.CommandType = CommandType.Text 'Set the timeout of the command object to 30 seconds mvarCommandObject.CommandTimeout = CommandTimeOut 'The SQL string that will be executed on the OleDB database mvarCommandObject.CommandText = mvarSQLString 'Set the current OleDbConnection instance mvarCommandObject.Connection = mvarConnectionObject 'Execute a SQL Statement that doesn't return rows Try mvarRecordsAffected = mvarCommandObject.ExecuteNonQuery() 'Return the value 'OK' Return "OK" Catch Ex As Exception 'Return any error message generated Return Ex.ToString End Try 'Close the database connection mvarConnectionObject.Close() 'Cleanup mvarCommandObject = Nothing mvarConnectionObject = Nothing mvarSQLString = Nothing End Function End Class End Namespace