HI All,
I am trying to connect Qt application with MS sql server 2005 with below code
database.setDatabaseName("DRIVER={SQL Server};SERVER=ITDPC\SQLEXPRESS;DATABASE=MTA;UID=sa;PWD=1;");
if(!database.open())
{
qDebug() << database.lastError().text();
QMessageBox::information(0,
"",
"DataBase Init Failed\n");
return 1;
}
else
{
return 0;
}
QSqlDatabase database = QSqlDatabase::addDatabase("QODBC3");
database.setDatabaseName("DRIVER={SQL Server};SERVER=ITDPC\SQLEXPRESS;DATABASE=MTA;UID=sa;PWD=1;");
if(!database.open())
{
qDebug() << database.lastError().text();
QMessageBox::information(0,"","DataBase Init Failed\n");
return 1;
}
else
{
return 0;
}
To copy to clipboard, switch view to plain text mode
But i am getting error
"[Microsoft][ODBC SQL Server Driver][DBNETLIB]Specified SQL server not found. [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). QODBC3: Unable to connect"
My Data source name is Addu. refer attached screen shot images
Please help to connect Qt application with MS Sql server.
Thanks
Yuvaraj
Bookmarks