Created
October 14, 2015 11:45
-
-
Save rjaeckel/7b4e9dba392a68a54bd9 to your computer and use it in GitHub Desktop.
Visual Basic DB Interface implemening IDisposable to connect and disconnect the Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Data.OleDb, Type = System.Data.OleDb.OleDbType | |
Public Class lazyDb | |
Implements IDisposable | |
Public Shared conCfg As String | |
Private db As OleDbConnection | |
Sub New() | |
db = New OleDbConnection(conCfg) | |
db.Open() | |
'MsgBox("DB open") | |
End Sub | |
Public Sub Dispose() Implements IDisposable.Dispose | |
db.Close() | |
'MsgBox("DB closed") | |
End Sub | |
Function query(str As String) As OleDbCommand | |
Return New OleDbCommand(str, db) | |
End Function | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment