SQLite connection from VBA

SQLite connection from VBA

mucip
Collaborator Collaborator
2,448 Views
2 Replies
Message 1 of 3

SQLite connection from VBA

mucip
Collaborator
Collaborator

Hi,

I installed both 32 and 64 bir SQLite ODBC driver from here. I used this code in VBA but "Out of Memory" error appear.

When I use 32 bit DSN then "wron architecture" message appear. My machine is 64 bit.

Dim conn As Object, rst As Object
    Dim strSQL As String

   Set conn = CreateObject("ADODB.Connection")
   Set rst = CreateObject("ADODB.Recordset")

  ' OPEN CONNECTION
   conn.Open "Dsn=SQLiteDatasource64;Database=c:\Kurdak.db;Version=3;"

  strSQL = "SELECT * FROM test "

  ' OPEN RECORDSET
   rst.Open strSQL, conn

   ' OUTPUT TO WORKSHEET
   Debug.Print rst
   rst.Close

  ' FREE RESOURCES
 Set rst = Nothing: Set conn = Nothing

 

Where am I wrong?

I wish we have "table and search in table utilities" in VBA. 😞

 

 

Regards,

Mucip:)

0 Likes
Accepted solutions (1)
2,449 Views
2 Replies
Replies (2)
Message 2 of 3

mucip
Collaborator
Collaborator
Accepted solution

Hi again,

I found solution to my own question and wants to share here.

I used X64 ODBC Driver

Dim conn As Object, rst As Object
    Dim strSQL As String

   Set conn = CreateObject("ADODB.Connection")
   Set rst = CreateObject("ADODB.Recordset")

  ' OPEN CONNECTION
   conn.Open "DRIVER=SQLite3 ODBC Driver;Database=c:\Kurdak.db;Version=3;"

  strSQL = "SELECT * FROM tartim "

  ' OPEN RECORDSET
   rst.Open strSQL, conn

   ' OUTPUT TO WORKSHEET
   Do Until rst.EOF
    Debug.Print rst.Fields(1)
    Debug.Print "----"
    
    
    rst.MoveNext
    Loop

   
   
   
   rst.Close

  ' FREE RESOURCES
 Set rst = Nothing: Set conn = Nothing

 

 

Regards,

Mucip:)

0 Likes
Message 3 of 3

mucip
Collaborator
Collaborator

Hi,

And also SQLite memory table connection string here:

conn.Open "DRIVER=SQLite3 ODBC Driver;Database=:memory:;Version=3;New=True;"

 

 

Regards,

Mucip:)

0 Likes