[Qt-interest] MSSQL Mac query

Wolfgang Kriener wkriener at fms-computer.de
Wed Jul 22 15:58:56 CEST 2009


Hi,

is anybody successful in connecting and retrieving data from a MS SQL  
Server using a Mac with OS X?
On my Mac i use the  Actual ODBC driver, which works using Excel or  
RealBasic...

i built plugin-sql-odbc as described in the Documentation except i  
used iodbc
qmake "INCLUDEPATH+=/Developer/SDKs/MacOSX10.5.sdk/usr/include" "LIBS 
+=-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib -liodbc"
make  - compiles with no error

For testing i made a small  workaround:

QSqlDatabase db;
db = QSqlDatabase::addDatabase("QODBC");
QString s = "DRIVER={Actual SQL  
Server};SERVER=myServerIP;UID=myUser;PWD=myPass;DATABASE=myDB";
// the same connect String i use to connect RealBasic and works
db.setDatabaseName( s );
db.setConnectOptions("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3");
if (db.open())
{
   QSqlQuery query;
   query.exec("SELECT * FROM TestTable");
   while (query.next()) {
     QString f1 = query.value(0).toString();
     QString f2 = query.value(1).toString();
     QString f3 = query.value(2).toString();
   }
}

db.open() reports no error as long as the database name (s) ist set up  
correct.
query.exec() ends with no result.

also a second  workaround using QSqlTableModel and model->select() the  
model stays empty.

any ideas?

Wolfgang




More information about the Qt-interest-old mailing list