PDA

View Full Version : SQL Connection Problem



Utku
24th October 2009, 20:57
Hello guys. My application works well on my PC. But if I try to use it on the PC which needs my application, it doesn't connect to SQL server. I tried ODBC (MySQL ODBC connector) and SQLite as database server. I don't know what causes to error; I've copied required DLLs, checked my connection code but found nothing.

Here is my connection function:



QSqlDatabase library::database()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Library");
bool ok = db.open();
if (!ok) { QMessageBox::critical(this, "Error!", "Can't connect to database."); }
return db;
}


Thanks in advance for your replies.

schnitzel
25th October 2009, 01:50
see if this post helps:
http://www.qtcentre.org/forum/f-installation-and-deployment-5/t-deploying-on-windows-24775.html

btw: are you setting the user credentials elsewhere?

Utku
25th October 2009, 12:31
btw: are you setting the user credentials elsewhere?


I'm setting them in Windows' own programme. It is under Control Panel > Administritive Tools > Data Sources

Utku
25th October 2009, 13:21
Thanks a lot schnitzel. I created a directory named "sqldrivers" and copied qsqlodbc.dll to under it. Works well now.