QODBC with MS SQL
-
I am trying to connect to a data base table I already made in Microsoft SQL Server Management Studio Express with Microsoft SQL Server 2005. This is how I am connectiong to it
@QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setHostName("ServerName");
db.setDatabaseName("DSNname");
db.setUserName("xxxx");
db.setPassword("xxxx");
if (!db.open()) {
QMessageBox::warning(0, QObject::tr("Database Error"),
db.lastError().text());
return false;
}
return true;@I am not getting a connection error anymore so I think it is connecting to the Data source fine but I can't figure out how to specify the specific database and table to get the information from. I know its there and has some informaiton in it because I ran the sqlbrowser demo and it connected to the correct database without me specifyting it (I assume because it is set as the default database) and then when I opened the table it had the information in it.
Can anyone tell me how to do this? Also could anyone tell me how to print it out to the screen in a table like form, I am following the guidelines of an example that used SQLITE so maybe its different and thats why?
-
Possibly "this":http://doc.qt.nokia.com/4.7-snapshot/sql-tablemodel-tablemodel-cpp.html can help.