Skip to content

Instantly share code, notes, and snippets.

@k4m4r82
Created February 10, 2016 11:04
Show Gist options
  • Save k4m4r82/de02c82aeceac1f83bd4 to your computer and use it in GitHub Desktop.
Save k4m4r82/de02c82aeceac1f83bd4 to your computer and use it in GitHub Desktop.
Option Explicit
Public Function GetOpenConnection() As ADODB.Connection
Dim conn As ADODB.Connection
Dim strCon As String
On Error GoTo errHandle
strCon = "DRIVER=SQLite3 ODBC Driver;Database=" & App.Path & "\db\Northwind.db;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0"
Set conn = New ADODB.Connection
conn.ConnectionString = strCon
conn.Open
Set GetOpenConnection = conn
Exit Function
errHandle:
' do nothing
End Function
Public Sub CloseConnection(ByVal conn As ADODB.Connection)
If Not conn Is Nothing Then
If conn.State = adStateOpen Then conn.Close
Set conn = Nothing
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment