VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SQLite connection from VBA

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mucip
1479 Views, 2 Replies

SQLite connection from VBA

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:)

2 REPLIES 2
Message 2 of 3
mucip
in reply to: mucip

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:)

Message 3 of 3
mucip
in reply to: mucip

Hi,

And also SQLite memory table connection string here:

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

 

 

Regards,

Mucip:)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost