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

donnyz at charter.net donnyz at charter.net
Sat Oct 30 15:59:08 EDT 2010


Yeah I see I missed that. After setting open it still failed. I used an odbc test tool with the same parameters and it still failed so it doesn't seem to be a vtk issue.  It is failing on the driver call SQLDriverConnect with SQL_INVALID_HANDLE -2
------Original Message------
From: Jim Peterson
To: Donny
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] vtkODBCDatabase used on an Access database file (.mdb)not working.
Sent: Oct 30, 2010 2:00 PM

Donny wrote:
>
> I am trying to access a Microsoft Access file (.mdb) using the 
> standard Microsoft Access ODBC Driver with vtkODBCDatabase but the 
> query returns an error of “Could not execute statement:”.
>
> Here is the code:
>
> //Initialize the latitude and longitude to zero for inspection upon return
>
> double latlon[2] = {0,0};
>
> //This is the format for using the Microsoft Access ODBC Driver as 
> defined here http://www.connectionstrings.com/access#p88
>
> //Driver={Microsoft Access Driver 
> (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;
>
> vtkODBCDatabase* db = vtkODBCDatabase::New();
>
> db->SetDataSourceName("Driver={Microsoft Access Driver 
> (*.mdb)};Dbq=\"C:\\Data\\app.3dd\";Uid=Admin;Pwd=;");
>
> vtkSQLQuery* query = db->GetQueryInstance();
>
> query->SetQuery("Select CenterLon, CenterLat FROM Sites WHERE SiteID = 
> 'KUEX'");
>
> if (query->Execute())
>
> {
>
> while(query->NextRow())
>
> {
>
> latlon[0] = query->DataValue(0).ToDouble();
>
> latlon[1] = query->DataValue(1).ToDouble();
>
> }
>
> }
>
> else
>
> {
>
> //I get an error of Could Not Execute Statement here
>
> const char* err = query->GetLastErrorText();
>
> }
>
> query->Delete();
>
> db->Delete();
>
> return latlon;
>
> The program compiles fine.
>
> I can retreive rows using the .NET OleDb driver from this database 
> using the exact same query so I know the tables are correct.
>
> I would like to see if I can retreive data using VTK.
>
> I am using Windows XP and VTK with C++ in Visual Studio 2005.
>
> Thanks.
>
> Donny Zimmerman
>
Sorry, for got to include the point....

I think you need db->open() before you can access the query.

Jim


Sent on the Sprint® Now Network from my BlackBerry®


More information about the vtkusers mailing list