1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
Public Sub Attachdb()
#If Win64 Then
Dim myDbHandle As LongPtr
Dim myStmtHandle As LongPtr
#Else
Dim myDbHandle As Long
Dim myStmtHandle As Long
#End If
Dim RetVal As Long
Dim PathFile As String
Dim NameFile As String
Dim TestFile As String
Dim InitReturn As Long
Dim stepMsg As String
#If Win64 Then
' I put the 64-bit version of SQLite.dll under a subdirectory called x64
InitReturn = SQLite3Initialize(ThisWorkbook.Path + "\x64")
#Else
InitReturn = SQLite3Initialize ' Default path is ThisWorkbook.Path but can specify other path where the .dlls reside.
#End If
If InitReturn <> SQLITE_INIT_OK Then
Debug.Print "Error Initializing SQLite. Error: " & Err.LastDllError
Exit Sub
End If
PathFile = Worksheets("Sheet1").Range("A1").Value
NameFile = Worksheets("Sheet1").Range("A2").Value
TestFile = PathFile + "\" + NameFile + ".db3"
RetVal = SQLite3Open(TestFile, myDbHandle)
Debug.Print "SQLite3Open returned " & RetVal
RetVal = SQLite3Close(myDbHandle)
Debug.Print "SQLite3Close returned " & RetVal
End Sub |