Can not connect Qt5.3.1 with MS SqlServer 2008R2.
-
hi,
I'm connecting Qt5.3.1 with MS SQL SERVER 2008R2 in Win 7, as following :-
@
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");QString dsn = QString("Driver=(SQL SERVER);SERVER=localhost\MSSQLSERVER;DATABASE=test_database;UID=sa;PWD=SA$Admin;");
db.setDatabaseName(dsn);
bool test;
test = db.isValid();if (test) //true QMessageBox::information(this,"ODBC Connectivity","database is valid"); test = db.isDriverAvailable("QODBC3"); if ( test ) //true QMessageBox::information(this,"ODBC driver availbility","driver is available"); if(db.open()) { QMessageBox::information(this,"test_database","database opened"); db.close(); } else { QMessageBox::information(this,"test_database",db.lastError().text()); }
@
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connects
and to display driveres availablability with this code to on messagebox :-
@
QStringList strlist = QSqlDatabase::drivers();
int i = 1;
QString str2 = "";
QString str = "";foreach (str, strlist) str2 += " " + QString::number(i++) + ". " + str; QMessageBox::information(this,"test_database",str2);
@
I found this message :-
- QSQLITE 2. QMYSQL 3. QMYSQL3 4. QODBC 5. QODBC3 6. QPSQL 7. QPSQL7
Where am I going wrong. Please tell me how to connect.