Hi,
I am trying to connect my application to Microsoft SQL Server managment studiio.
First of all if I do following statement to print drivers.
qDebug << QSqlDatabase::drivers();
To copy to clipboard, switch view to plain text mode
It prints "QSQLLITE", "QODBC","QODBC3".
I have attached file as screenshot to display what database i am trying to connect.
Now I try to connect
db.setDatabaseName("db1");
db.setHostName("localhost");
db.setUserName("test");
db.setPassword("test");
bool ok = db.open();
if( db.open() )
{
qDebug( "Database successfully opened, now able to query" );
}
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("db1");
db.setHostName("localhost");
db.setUserName("test");
db.setPassword("test");
bool ok = db.open();
if( db.open() )
{
qDebug( "Database successfully opened, now able to query" );
}
To copy to clipboard, switch view to plain text mode
However my connection fails. I am not quite sure if QDBC3 drivers works fine with Microsoft SQL Server Management studio 2008.
I have seen at some other posts that lot of other people used syntax like this while setting database name
db.setDatabaseName("DRIVER=FreeTDS;SERVER=localhost;Port=1433;DATABASE=db_test;TDS_Version=8.0;uid=SomeUser;pwd=SomePassword");
db.setDatabaseName("DRIVER=FreeTDS;SERVER=localhost;Port=1433;DATABASE=db_test;TDS_Version=8.0;uid=SomeUser;pwd=SomePassword");
To copy to clipboard, switch view to plain text mode
Which drivers are compatible with Microsoft SQL Server Management studio 2008.
If somebody can guide me what i am doing wrong here that would be great?Database.jpgDatabase.jpg
Bookmarks