Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ODBC driver use in Qt

Tags:

qt

odbc

ms-access

I wanted to use read and write mdb file (Ms Access file) and I am completely new in using ODBC in Qt.

So can anyone help me to know whether should i need to download the drivers and if yes then from where can i download ? and if you know about connectivity then any help would be appriciated.

like image 476
Chiku Avatar asked Oct 29 '10 10:10

Chiku


People also ask

What is ODBC driver used for?

An ODBC driver uses the Open Database Connectivity (ODBC) interface by Microsoft that allows applications to access data in database management systems (DBMS) using SQL as a standard for accessing the data. ODBC permits maximum interoperability, which means a single application can access different DBMS.

What is ODBC Driver for SQL Server?

Microsoft ODBC Driver for SQL Server is a single dynamic-link library (DLL) containing run-time support for applications using native-code APIs to connect to SQL Server.

Can I use ODBC for SQL Server?

ODBC is the primary native data access API for applications written in C and C++ for SQL Server. There's an ODBC driver for most data sources. Other languages that can use ODBC include COBOL, Perl, PHP, and Python.


2 Answers

If you need to access an MS Access database with Qt, you don't need (if I'm not mistaken) to install anything regarding drivers (everything should be already there).

You can connect to a database with a connection string. Something like this :

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=C:\\path\\to\\mydatabase.mdb");
bool Success = db.open();
like image 128
Jérôme Avatar answered Sep 19 '22 02:09

Jérôme


I had the same Problem.

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC","AccessDB");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=C:/path/to/Database.mdb");
bool success = db.open();

works for me.

like image 21
Haselnussstrauch Avatar answered Sep 21 '22 02:09

Haselnussstrauch