Hi Everyone
I Get Error in ODBC when i open connect To DataBase
Error:
[Microsoft][ODBC Driver Manager] Data Source Name Not Found and No Default Driver
specified QODBC3: Unable To Connect
[Microsoft][ODBC Driver Manager] Data Source Name Not Found and No Default Driver
specified QODBC3: Unable To Connect
To copy to clipboard, switch view to plain text mode
and I Used This Code:
QString servername
="LOCALHOST\\SQLEXPRESS";
db.setConnectOptions();
QString dsn
=QString("Driver=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Yes;").
arg(servername
).
arg(dbname
);
db.setDatabaseName(dsn);
if(db.open())
{
}
QString servername="LOCALHOST\\SQLEXPRESS";
QString dbname="Test";
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setConnectOptions();
QString dsn=QString("Driver=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Yes;").arg(servername).arg(dbname);
db.setDatabaseName(dsn);
if(db.open())
{
QMessageBox::about(this,"","OK");
}
QMessageBox::about(this,"",db.lastError().text());
To copy to clipboard, switch view to plain text mode
Thanks
Bookmarks