Skip to content

Instantly share code, notes, and snippets.

@rjaeckel
Created October 14, 2015 11:45
Show Gist options
  • Save rjaeckel/7b4e9dba392a68a54bd9 to your computer and use it in GitHub Desktop.
Save rjaeckel/7b4e9dba392a68a54bd9 to your computer and use it in GitHub Desktop.
Visual Basic DB Interface implemening IDisposable to connect and disconnect the Database
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