[vtkusers] vtkODBCDatabase used on an Access database file (.mdb)notworking.

Donny donnyz at charter.net
Sat Oct 30 17:38:48 EDT 2010


Sorry that correct working code is:

db->SetDataSourceName("DRIVER={Microsoft Access Driver
(*.mdb)};Dbq=C:\\app.3dd;");

db->SetUserName("Admin");

-----Original Message-----
From: Donny [mailto:donnyz at charter.net] 
Sent: Saturday, October 30, 2010 4:36 PM
To: 'Jim Peterson'
Cc: 'vtkusers at vtk.org'
Subject: RE: [vtkusers] vtkODBCDatabase used on an Access database file
(.mdb)notworking.

Thanks Jim!! With your help I figured out what I was doing wrong. I was
putting the path in quotes and that is why you see the escape character '\'
before the extra quotes. I also should not have been putting the User id in
the source name. Here is the code that works:

db->SetDataSourceName("DRIVER={Microsoft Access Driver
(*.mdb)};Dbq=C:\\app.mdb;");

db->SetUserName("Admin");

One thing I noticed was that the source code for vtkODBCDatabase is looking
for the string DRIVER in the source name to set the correct connection
string schema. Most online odbc examples show this word in lower case
(Driver not DRIVER) as the first word of the source. My code does not work
unless I change it to upper case when calling SetDataSourceName. A nice
change would be to look for both DRIVER or Driver in the source name.

To answer your other question, I changed my file from app.mdb to app.3dd and
it opens fine no matter which file extension I use. I think the extension is
just to associate the file to an application to open the file with.

-----Original Message-----
From: Jim Peterson [mailto:jimcp at cox.net] 
Sent: Saturday, October 30, 2010 4:02 PM
To: donnyz at charter.net
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] vtkODBCDatabase used on an Access database file
(.mdb)notworking.

donnyz at charter.net wrote:
> Sorry. It is failing on the db->open call. I set DebugOn on the db and
looked at the source code for vtkODBCDatabase and I can verify that the
SQLDriverConnect call is where it is failing which is also the call that is
failing with my odbc test tool. I will have to do some checking on how to
set the proper DataSource on an odbc driver.  Thanks for the help. 
>   
The only curious part I could see was this setting of the connection string:

db->SetDataSourceName("Driver={Microsoft Access Driver
(*.mdb)};Dbq=\"C:\\Data\\app.3dd\";Uid=Admin;Pwd=;");

why exactly do you have the extra " in the dbq string? and is your 
access database actually not named .mdb? can access open it by 
association that way?

Hope that helps,
Jim




More information about the vtkusers mailing list