RE: Need help with sqlite3.dll

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Norm,

From your description, you're dealing with some VB6 program which maniplate
some SQLite database, correct?

I haven't used SQLite database much, based on my research, here are some
reference about manipulating SQLite database via VB6 code:

http://www.kirupa.com/net/sqllite_vb_pg2.htm

http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers&1057833364

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Norm" <NormF4@xxxxxxxxxxxxxxxxx>
Subject: Need help with sqlite3.dll
Date: Mon, 6 Oct 2008 16:09:02 -0700

Hi,

I am trying to open and manipulate a sqlite database, containing cookie
information in FireFox browser.

I have an application that I use which removes all the cookies I don't
want
to save and worked just fine until FireFox changed to a sqlite type
database. :-)

I am trying a wrapper which I can get to open the database and list all
the
items contained in a listview control. But I cannot figure out how to
delete
the ones I don't want.

If anyone knows of a better way to do this please let me know.

Thanks,
Norm

Code:
Option Explicit

'// SQL Lite dll declarations:

Private Declare Sub sqlite3_open Lib "SQLite3VB.dll" (ByVal FileName As
String, ByRef handle As Long)
Private Declare Sub sqlite3_close Lib "SQLite3VB.dll" (ByVal DB_Handle As
Long)
Private Declare Function sqlite3_last_insert_rowid Lib "SQLite3VB.dll"
(ByVal DB_Handle As Long) As Long
Private Declare Function sqlite3_changes Lib "SQLite3VB.dll" (ByVal
DB_Handle As Long) As Long
Private Declare Function sqlite_get_table Lib "SQLite3VB.dll" (ByVal
DB_Handle As Long, ByVal SQLString As String, ByRef ErrStr As String) As
Variant()
Private Declare Function sqlite_libversion Lib "SQLite3VB.dll" () As
String
' Now returns a BSTR

'// This function returns the number of rows from the last sql statement.
Use this to ensure you have a valid array
Private Declare Function number_of_rows_from_last_call Lib "SQLite3VB.dll"
() As Long
Dim DB As Long


Private Sub Form_Load()
' Display the SQLite3VB version
Caption = "Cookies Listed In FireFox V.3 Profiles File"
StartQueary
End Sub
Private Sub StartQueary()
Dim mRetErr As String ' Will hold an error string if one is
encountered
Dim mResultCnt As Long
Dim mDBFile As String
Dim mQuery As String
Dim i As Long
mQuery = "SELECT * FROM moz_cookies" 'Text2.Text
mDBFile = App.Path & "\" & "cookies.sqlite" 'mDBFile
lvResults.ListItems.Clear
lvResults.ColumnHeaders.Clear
SB1.SimpleText = "Querying database"

mResultCnt = DBQuery(mDBFile, mQuery, mRetErr)
If mRetErr <> "" Then
MsgBox mRetErr, vbCritical, "SQLite Database Error"
End If
SB1.SimpleText = mResultCnt & " Cookies Listed In File!"
For i = 1 To lvResults.ColumnHeaders.Count
If lvResults.ColumnHeaders.Item(i).Text = "host" Or
lvResults.ColumnHeaders.Item(i).Text = "name" _
Or lvResults.ColumnHeaders.Item(i).Text = "expiry" Then
Else
lvResults.ColumnHeaders.Item(i).Width = 0
End If
Next i
DoEvents
Sleep 100
Set lvResults.SelectedItem = lvResults.ListItems.Item(1)
End Sub
Private Function DBQuery(ByVal DBFile As String, ByVal QueryStr As String,
ByRef ErrStr As String) As Long
On Error GoTo ERR_TRAP
Dim i As Long
Dim mVar As Variant ' Will hold our results
Dim mV1 As Variant ' Will be used to get each individual result
Dim mErrStr As String
Dim mStr As String
Dim mRowCnt As Long
Dim mCurColumn As String
Dim LI As ListItem
If QueryStr = "" Or DBFile = "" Then Exit Function
sqlite3_open DBFile, DB
If DB > 0 Then
mVar = sqlite_get_table(DB, QueryStr, mErrStr)
If mErrStr <> "" Then
ErrStr = mErrStr
sqlite3_close DB
Exit Function
Else
mRowCnt = number_of_rows_from_last_call
If mRowCnt > 0 Then
For Each mV1 In mVar
mStr = mV1
If i = 0 Then
mCurColumn = mStr
lvResults.ColumnHeaders.Add , mCurColumn,
mCurColumn
Else
If lvResults.ColumnHeaders.Count = 1 Then
lvResults.ListItems.Add , , mStr
ElseIf lvResults.ColumnHeaders.Count > 1 Then
Set LI = lvResults.ListItems(i)
LI.SubItems(lvResults.ColumnHeaders.Count - 1)
=
mStr
End If
End If
i = i + 1
If i > mRowCnt Then
i = 0
End If
Next
End If
End If
'sqlite3_close DB
End If
DBQuery = lvResults.ListItems.Count
Exit Function
ERR_TRAP:
ErrStr = Err.Description
End Function

Private Sub Form_Unload(Cancel As Integer)
Dim mDBFile As String
mDBFile = App.Path & "\" & "cookies.sqlite" 'mDBFile

sqlite3_close DB
End Sub



.



Relevant Pages

  • Re: Playing AVI and MPEG using MCI
    ... "mciSendStringA" (ByVal lpstrCommand As String, ... Dim mlRet As Long ... Private Sub CenterObject ... If mlRet 0 Then ...
    (microsoft.public.vb.controls)
  • Change this Program
    ... Private sPathFrom As String ... Private Sub enableControl ... Dim oColor As OLE_COLOR ... Dim sPathTo As String ...
    (microsoft.public.vb.general.discussion)
  • Re: Error when running vb app with FlexGrid control
    ... Private Sub cmdNetChange_Click ... On Error GoTo Command1_Click_Error ... Private Sub fnGetData(strParam0 As String, strParam1 As String, FLX As ... Dim rsADOObject As Recordset ...
    (microsoft.public.vb.general.discussion)
  • Sum in a dynamic query
    ... Private Sub Form_Open ... Dim db As Database, Tbl As TableDef ... Dim db As Database, qd As QueryDef, ctl As Control, s As String, Item As ...
    (comp.databases.ms-access)
  • Re: How to add/load records to combobox ?
    ... Dim rsCustomers As New ADODB.Recordset ... Private msCustomerIDsAs String ... Private Sub Combo1_Click ... Dim sSQL As String ...
    (microsoft.public.vb.controls)