user_mail07
10th May 2011, 01:10
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();
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
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" );
}
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=SomePass word");
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?63916391
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();
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
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" );
}
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=SomePass word");
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?63916391