Help!

From SQLite to Excel with ODBC

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Query DAO RSS
Next:  Gridlines  
Author Message
Florian Mauderer
External


Since: Nov 03, 2005
Posts: 2



PostPosted: Thu Nov 03, 2005 4:15 pm    Post subject: From SQLite to Excel with ODBC
Archived from groups: microsoft>public>excel>querydao (more info?)

Hello,



I would like to access from Excel 2003 (OS: Windows XP) to a SQLite-Database
with ODBC.



I did the following steps:



1.) Install SQLite-ODBC-driver:



From http://www.ch-werner.de/sqliteodbc/ I downloaded the file
"sqliteodbc.exe" which installs the ODBC-driver on my computer. I saw after
the installation on the "ODBC-datasources/System-DSN"-menu three new entries
("SQLite Datasource", "SQLite UTF-8 Datasource" und "SQLite3 Datasource").



2.) Create an SQLite-database:



From http://sourceforge.net/projects/sqlitebrowser/ I got a SQLiteBrowser
(version 1.2.1) and I created one new database ("TestDB") with three tables
and I put few data inside. I saved the database under "C:\Test.db".



3.) Create USer-DSN:



On "ODBC-datasources/User-DSN" I accomplished the following steps:



"Add"

"SQLite ODBC Driver"

"Finish"

Data Source Name: TestDB

Database Name: C:\Test.db

"Ok"



4.) Get the data in Excel:



In Excel I made the following:



"Data/Import external data/Import data.."

"+Create new datasource.odc" + "Open"

"ODBC DSN" + "continue"

"TestDB" + "continue"

(mask "SQLite ODBC Driver Connect" appears)

"OK"

(mask "Dataconnectionproperties" appears)

"OK"

(Maske "SQLite ODBC Driver Connect" appears again)

When I push "OK" I get an error message that I have no access and so on.



Alternatively I accomplished step 1.) until 3.) und wrote the following code
in VBA:



Sub TestDB()

Dim ws As Workspace

Dim con As Connection

Dim rs As Recordset



Set ws = DBEngine.CreateWorkspace("ws1", "", "", dbUseODBC)

Workspaces.Append ws

Set con = ws.OpenConnection("con1", dbDriverComplete, False,
"ODBC;DSN=TestDB") 'Test = DSN-Name

Set rs = con.OpenRecordset("select * from TabPerson")



' Enumerate the specified Recordset object.

With rs

Do While Not .EOF

'Debug.Print , .Fields(0), .Fields(1)

MsgBox .Fields(0)

.MoveNext

Loop

End With



rs.Close

con.Close

ws.Close

End Sub



When I call this procedure I get the following error message:



"Run time error '3146'



What is wrong?



Thanks a lot



Florian
Back to top




User: inactive
Posts:



PostPosted: Wed Aug 09, 2006 2:50 am    Post subject: Re: From SQLite to Excel with ODBC [Login to view extended thread Info.]

I have the same symptoms as you. Did you ever find a solution?

I can link to or import the SQLite db in MS Access 2003 but nothing in Excel 2003 using the same System DSN.

Here is what I did:

Installed SQLite ODBC driver on a WinXP PC.
Configured a System DSN
Open Excel
> Data
> Import External Data
> Import Data
> New Source (button)
> Other/Advanced
> Connection (tab)
> select the System DSN (that I created previously) in the Data Source Name drop down
> OK (leaving uid, pw and intitial catelog left blank)

<Dialog Box>

Microsoft Excel
The Data Connection Wizard cannot obtain a list of databases from the specificed data source.

>OK
</Dialog Box>

TIA
Back to top




User: inactive
Posts:



PostPosted: Mon Aug 14, 2006 11:43 pm    Post subject: A reply from Christian [Login to view extended thread Info.]

TechMason wrote:
>
> Hi Christian,
>
> First off I would like to thank you for the SQLite ODBC Driver that you have
> written.
>
> I hope that I am not bothering you with my newbie questions but I have
> searched high and low on the net for a solution to my problem to no avail.
> The only thing that I found was someone else with the same problem, but no
> solution @
> http://help.lockergnome.com/office/SQLite-Excel-ODBC-ftopict704125.html
>
> I downloaded and installed you ODBC driver but I am having problems with it
> working with Excel 2003. Any help you can provide would be greatly
> appreciated.

Tech,

I'm aware of an annoying behaviour of Excel'97 and Excel 2000 regarding
"Database does not contain visible tables". After changing the check marks
"Views" and/or "System Tables" it is possible to see all SQLite ODBC
tables and make queries with M$Query. Is it this problem you observe
with Excel 2003 ?

Regards,
Christian


Hi Christian,

I was trying to do a straight import which didn't give me any options for views or tables but I tried doing a "New Database Query" and it does work, sort of the way you indicated. Here is the (annoying) procedure that got me some data:
> Open Excel
> Data
> Import External Data
> New Database Query
> Select my System DSN from the list of databases.
--- No tables show up in the list
> Click Options
> change any checkbox or hit refresh and then OK.
--- All tables now show and are selectable.

It seems that the intial ODBC connection fails to grab the tables but if an attempt to re-read is done then all is well.

Any ideas what the underlying problem is?

Thank you,
TechMason
Back to top
dummy1234



Joined: May 02, 2008
Posts: 1



PostPosted: Fri May 02, 2008 3:50 pm    Post subject: [Login to view extended thread Info.]

I ran into the problem you described and found a fix that seemed to work for me trying to connect using both MS Access and MS Excel. Check out this post for the workaround I used

http://help.lockergnome.com/office/SQLite-ftopict659422.html

The gist of the thing is that you need to add a registry value to
\HKLM\SOFTWARE\ODBC\ODBC.INI\<your DSN type>

It's a string value:
WorkArounds2 = 8192
Back to top
alnz123



Joined: Oct 19, 2008
Posts: 1



PostPosted: Sun Oct 19, 2008 10:34 pm    Post subject: using ODBC with Access [Login to view extended thread Info.]

Hi Christian

I can't get the "Link Tables" to work.
The Import works but when I try to "link" to a SQLite 3 database the data is shown as #Deleted even though it isn't
Same issue in both Access 2003 and 2007

By adding the registry entry, there is no effect (the post that is mentioned doesn't seem to help)

Alan
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Query DAO All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum