I am trying to connect my qt application to ms sql database. I dont know server machine's IP addres and PORT number. I allready have Data Source Name in System DSN. Here is the sample of my code :
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={SQL Server};SERVER={serverName};DATABASE=dbname;UID=username;PWD=password;WSID=.;Trusted_connection=yes");
bool ok = db.open();
if(ok == true){
qDebug()<<"connected";
}
else{
qDebug()<<"not connected";
qDebug()<<db.lastError().text();
}
And i get this error :
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'xxx'. QODBC3: Unable to connect.
Any help will be appreciated.