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

Jim Peterson jimcp at cox.net
Sat Oct 30 18:36:07 EDT 2010


Donny wrote:
> 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.
>
>   
Donny,
Good work, Glad I could help a little. I would settle for a comment that 
shows up in the doc that says the driver parameter of the connect string 
needs to be all caps. I agree it either case works in Windows, but I am 
not sure about ODBC on all other platforms.

Have fun,
Jim



More information about the vtkusers mailing list