Hi
How I Connect To SQL Server DataBase With QT
(I Tested QODBC)But Driver Not Loaded
Thanks
Hi
How I Connect To SQL Server DataBase With QT
(I Tested QODBC)But Driver Not Loaded
Thanks
QODBC for Open Database Connectivity (ODBC)
Make sure the ODBC plugin is built and present on your machine: is should show in the output of QSqlDatabase::drivers().
Make sure a suitable SQL Server ODBC driver is installed on your machine.
Make sure your ODBC DSN is set up/correct.
Only the first point has much to do with Qt.
Hello Metor,
First of all you need to check that respective Qt odbc driver is available or not on path "C:\Qt\2010.05\qt\plugins\sqldrivers".At this path following file shoulb be present to make connectivity with sql server DB.
libqsqlodbc4.a
libqsqlodbcd4.a
qsqlodbc4.dll
qsqlodbcd4.dll
If above files are not present then you need to build odbc driver for your QT and after that you need to create DSN for your odbc driver.
Thanks For All But How I Do That
Use Below code to check DB connectivity If driver is not present then it will throw the error.
bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("DSNName");
db.setHostName("SystemHostName");
db.setDatabaseName("DSNName");
db.setUserName("DBUserName");
db.setPassword("UrDBpassword");
//Checking DB connection
if(!db.open())
{
QMessageBox::critical(0,QObject::tr("DATABASE OPEN"),db.lastError().text());
return false;
}
return true;
}
Last edited by lekhrajdeshmukh; 12th December 2011 at 05:09.
How do you do what? Check that the Qt driver plugin exists, build the Qt plugin, check that a suitable MS SQL Server ODBC driver exists, build a suitable ODBC DSN, check that the connection is working...?
The first two items are covered in my last post and the page I linked to.
How I Build Plugin Please Explain Details
Thanks
Bookmarks