You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, June 29th 2011, 6:48pm

QODBC - How to specify driver's path in "DRIVER" parameter

Hi there,

I'm using QODBC with my application and I would like to pass driver's path instead of a name while adding a new database to QSqlDatabase. Actually, I have this code:

Source code

1
2
3
4
5
QString connectionString = "DRIVER={SQL SERVER};SERVER=192.168.0.1,1433;DATABASE=Test;";
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName(connectionString);
db.setUserName("username");
db.setUserPassword("password");


where SQL SERVER is the name of the driver that I use (and is listed in e.g. Windows' ODBC Administrator). I'd like to pass the path to the driver, because I am not sure if users that will use the app will have such driver properly installed in "ODBC Data Sources". I'd rather not rely on settings from OS.

Does anyone know how to achieve this?

Cheers!