Open SQLite database (.sqlite file)
I've tryed to connect to a SQlite database (with this extension: .sqlite) using: AG_SQLite.dll.
But when I connect to the database and try to get all data it gives me an error:
Code:
Option Explicit
Private strFilename As String
Private Sub Command1_Click()
strFilename = "C:\data.sqlite"
ok
End Sub
Public Sub ok()
Dim DB_Handle As Long
Dim strErrMsg As String
Dim TableArray() As Variant
Dim strQuery As String
Dim intCounter1 As Integer
Dim intRecords As Integer
strQuery = "Select * From ASDTable"
DB_Handle = ModSqlite.sqlite_open(strFilename, 0, strErrMsg)
TableArray = ModSqlite.ags_sqlite_get_table(DB_Handle, strQuery, strErrMsg)
intRecords = ModSqlite.ags_number_of_rows_from_last_call
If intRecords > 0 Then
For intCounter1 = 1 To UBound(TableArray)
Text1.Text = Text1.Text & TableArray(intCounter1)
Next intCounter1
sqlite_close DB_Handle
Else
MsgBox "error"
End If
End Sub
Module /declarations:
Code:
Option Explicit
Public Declare Function sqlite_open Lib "AGS_SQLite.dll" (ByVal filename As String, ByVal mode As Long, ByRef errstr As String) As Long
Public Declare Sub sqlite_close Lib "AGS_SQLite.dll" (ByVal DB_Handle As Long)
Public Declare Function sqlite_last_insert_rowid Lib "AGS_SQLite.dll" (ByVal DB_Handle As Long) As Long
Public Declare Function sqlite_changes Lib "AGS_SQLite.dll" (ByVal DB_Handle As Long) As Long
Public Declare Function sqlite_libversion Lib "AGS_SQLite.dll" () As String
Public Declare Function sqlite_libencoding Lib "AGS_SQLite.dll" () As String
Public Declare Function ags_sqlite_get_table Lib "AGS_SQLite.dll" (ByVal DB_Handle As Long, ByVal SQLString As String, ByRef errstr As String) As Variant()
Public Declare Function ags_sqlite_libversion Lib "AGS_SQLite.dll" () As String
Public Declare Function ags_number_of_rows_from_last_call Lib "AGS_SQLite.dll" () As Long
I've tryed with other DLLs and methods but no success :(
Can someone give me a working example of reading data from a .sqlite file?!
Re: Open SQLite database (.sqlite file)
Try using the SQLLite ODBC Driver
Re: Open SQLite database (.sqlite file)
1 Attachment(s)
Re: Open SQLite database (.sqlite file)
Quote:
Originally Posted by
LoopUntil
Some other solution?
helo
this example for you ...
Code:
Public Sub LoadGrid()
Dim DB_Handle As Long
Dim strErrMsg As String
Dim TableArray() As Variant
Dim intRecords As Integer
Dim strQuery As String
Dim intCounter1 As Integer
Dim OutputString As String
'/* clear list
Lst_Teca.ListItems.Clear
'/* path base
FILE_Database = App.Path & "\store.db" '[ local]
strQuery = "Select * from Archivio"
DB_Handle = ModSqlite.sqlite_open(FILE_Database, 0, strErrMsg)
If DB_Handle <> 0 Then
TableArray = ModSqlite.ags_sqlite_get_table(DB_Handle, strQuery, strErrMsg)
If Len(strErrMsg) = 0 Then
intRecords = ModSqlite.ags_number_of_rows_from_last_call
If intRecords > 0 Then '/*
For intCounter1 = 1 To UBound(TableArray, 1)
OutputString = ""
'/* show records on list ---------------------------
With Lst_Teca.ListItems.Add
'/* [CodiceID]
10 .Text = TableArray(intCounter1, 0)
'/* [Titolo]
20 .SubItems(1) = TableArray(intCounter1, 1)
'/* [Sottotitolo]
30 .SubItems(2) = TableArray(intCounter1, 2)
'/* [Artista1]
40 .SubItems(3) = TableArray(intCounter1, 3)
'/* [Artista2]
50 .SubItems(4) = TableArray(intCounter1, 4)
'/* [Artista3]
60 .SubItems(5) = TableArray(intCounter1, 5)
'/* [Album]
70 .SubItems(6) = TableArray(intCounter1, 6)
'/* [Traccia]
80 .SubItems(7) = TableArray(intCounter1, 7)
'/* [Tema]
90 .SubItems(8) = TableArray(intCounter1, 8)
'/* [Genere]
100 .SubItems(9) = TableArray(intCounter1, 9)
'/* [Tempo]
110 .SubItems(10) = TableArray(intCounter1, 10)
'/* [Energia]
120 .SubItems(11) = TableArray(intCounter1, 11)
'/* [CodCategoria]
130 .SubItems(12) = TableArray(intCounter1, 12)
'/* [IndiceGradimento]
140 .SubItems(13) = TableArray(intCounter1, 13)
'/* [CodiciAudio]
150 .SubItems(14) = TableArray(intCounter1, 14)
'/* [ImmagineAlbum]
160 .SubItems(15) = TableArray(intCounter1, 15)
'/* [NMaxPassaggi]
170 .SubItems(16) = TableArray(intCounter1, 16)
'/* [NMinPassaggi]
180 .SubItems(17) = TableArray(intCounter1, 17)
'/* [SeparazioneBrano]
190 .SubItems(18) = TableArray(intCounter1, 18)
'/* [Abilitadal]
200 .SubItems(19) = TableArray(intCounter1, 19)
'/* [Abilitafinoal]
210 .SubItems(20) = TableArray(intCounter1, 20)
'/* [DATAGRID]
220 .SubItems(21) = TableArray(intCounter1, 21)
'/* [HOURGRID]
230 .SubItems(22) = TableArray(intCounter1, 22)
'/* [Fadein]
240 .SubItems(23) = TableArray(intCounter1, 23)
'/* [Start]
250 .SubItems(24) = TableArray(intCounter1, 24)
'/* [COUNTDOWN]
260 .SubItems(25) = TableArray(intCounter1, 25)
'/* [Fine]
270 .SubItems(26) = TableArray(intCounter1, 26)
'/* [FadeOut]
280 .SubItems(27) = TableArray(intCounter1, 27)
'/* [RitornelloIntro]
290 .SubItems(28) = TableArray(intCounter1, 28)
'/* [RitornelloEnd]
300 .SubItems(29) = TableArray(intCounter1, 29)
'/* [RitornelloOut]
310 .SubItems(30) = TableArray(intCounter1, 30)
'/* [Volume]
320 .SubItems(31) = TableArray(intCounter1, 31)
'/* [InfoFile]
330 .SubItems(32) = TableArray(intCounter1, 32)
'/* [Passaggio1]
340 .SubItems(33) = TableArray(intCounter1, 33)
'/* [Passaggio2]
350 .SubItems(34) = TableArray(intCounter1, 34)
'/* [Passaggio3]
360 .SubItems(35) = TableArray(intCounter1, 35)
'/* [Passaggio4]
370 .SubItems(36) = TableArray(intCounter1, 36)
'/* [CancellazioneAutomatica]
380 .SubItems(37) = TableArray(intCounter1, 37)
'/* [AudioContenuti]
390 .SubItems(38) = TableArray(intCounter1, 38)
'/* [AudioinConflitto]
400 .SubItems(39) = TableArray(intCounter1, 39)
'/* [Empty1]
410 .SubItems(40) = TableArray(intCounter1, 40)
'/* [Empty2]
420 .SubItems(41) = TableArray(intCounter1, 41)
'/* [Empty3]
430 .SubItems(42) = TableArray(intCounter1, 42)
'/* [Empty4]
440 .SubItems(43) = TableArray(intCounter1, 43)
'/* [Empty5]
450 .SubItems(44) = TableArray(intCounter1, 44)
End With
Next intCounter1
Else
MsgBox "no record found"
End If
Else
MsgBox strErrMsg, vbOKOnly, "SQLite Error"
End If
sqlite_close DB_Handle
Else
MsgBox "Error on open data"
End If
End Sub
and full example with AGS_SQLite.dll
ps : any extension of file is equal example : .db .sql .sqlite ..ecc
example : data.sqlite / data.db / data.sql / data.dat ... ecc
bye from sicily (Enna) :wave: :wave:
Re: Open SQLite database (.sqlite file)