Qt database
-
hiii...this is my first database app using Qt and i dont know what is wrong any help??
@#include <QtCore/QCoreApplication>
#include <QtSql>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
//127.0.0.1
QString servername = "localhost\SQLEXPRESS";
QString dbname = "MyDatabase";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()) { qDebug()<<"connected finallyyyyyyyyyy :D:D:D:D"; }else{ qDebug()<<db.lastError().text(); qDebug() << QSqlDatabase::drivers(); } return a.exec();
}
@ -
"[Microsoft][ODBC Driver Manager]Data source name not found and no default driver specified QODBC3:Unable to connect"
-
ok thx alot...what will be the server name if i will use MS access??...excuse my bad question I am a DB beginner ;)
-
"This":http://www.connectionstrings.com/ will help you.
-
thank you very much =)