[SOLVED] Qt 4.7.3, ODBC driver, error when connecting to db
-
What do you mean by system driver?
I have compiled a Qt ODBC driver for 64 bit yes. -
You always need the drivers for your database and some generic system drivers for ODBC. Qt uses those to wrap the calls into its own database abstraction layer. If only one of those is missing, the driver cannot be loaded. So make sure you have 64bit versions of the system ODBC and of the driver for your specific database.
-
Ok. It seems I understood what you mean.
I'm using win 7 x64 for both cases.
I'm sure that I have a correct Qt database driver (Otherwise Qt generates another error smth like "QODBC not loaded"). Now we are coming to system driver. I guess you mean OS driver, something like "odbcad32.exe" right?
My assumption is that this it is loading automatically, since so far I had no problems with that.
But may be you are right, does that means that Windows is loading a 32 bit driver (on 64 bit system) by default and I need 64 bit one? Do you know anything how to switch them? -
As long as your application is 64bit, all loaded libs must be 64bit too. As your application works as 32bit version, it's very likely that you do not have the 64bit drivers installed or in the right path. Fortunately I didn't have to deal with ODBC so far, so unfortunately for you I cannot be of big help here :-)
-
Yes, my all libs all are 64 bit (for case 2), but it seems that the ODBC driver comes with the Office (and it is 32 bits in my case ). It is possible to install "MS AccessDatabaseEngine X64", but then office is not working correctly any more. (according to the forum here (sorry in German) http://www.windows-7-forum.net/windows-7-software/15054-32-bit-64-bit-odbc-problem.html )
But anyway, thanks for pointing me to the right direction, now I know at least where to search :-)
-
The solution was really easy:
The connection string must be exactly this@
"DRIVER={Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)};DBQ=".
@Without those stupid "*.ndx, *.mdx" it doesn't work on x64 but works perfectly on x86.
(Database is *.dbf)
I "love" Microsoft :-)[EDIT: code formatting for the string, Volker]
-
"_db_path" is just a path to your DB directory, i.e. the location of your DBF files. Note, that you don't need to include a "DBF" filename here, only the path to the directory. The DBF can be accessed then like following:
"SELECT * FROM YOURFILENAME.DBF" -
No. "_db_path" is appended to the connection string (in the above example).
I mean that you should include only the folder name into the "_db_path".
The filename is used as a table name in the sql query. "SELECT ..." is the SQL query of course. -
Oh Ok. Sorry I'm new to Qt and SQL and. So I would replace _db_path with "C:\Users..." pointing to the folder the .dbf is in? Also can you tell me how to create the .dbf? The only examples I've seen use SQLlight and .dat files so I can't figure out how to make the .dbf or just access a database I made directly in SQL. Would I just add the disired filename here
@QString connect_str("DRIVER={Microsoft dBASE Driver (*.dbf)};DBQ=");@like this
@QString connect_str("DRIVER={Microsoft dBASE Driver (*.dbf)};DBQ=filename");@ -
[quote author="confused" date="1342446698"]So I would replace _db_path with "C:\Users..." pointing to the folder the .dbf is in? [/quote]
Yes
[quote author="confused" date="1342446698"]
Also can you tell me how to create the .dbf?
[/quote]You should execute a query "CREATE TABLE YOURFILE.DBF"