the code:
Qt Code:
  1. QString error;
  2. QString conn = "Data Source=.\\SQLEXPRESS;Initial Catalog=master;Integrated Security=False;Persist Security Info=False;"
  3. "User ID=sa;password=[]";
  4.  
  5. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MainDBConnection");
  6. db.setDatabaseName(conn);
  7. db.setUserName("sa");
  8. db.setPassword("[]");
  9.  
  10. if (!db.open())
  11. error = db.lastError().text();
To copy to clipboard, switch view to plain text mode 

but it not works, error == "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect"

while following run, when i use mssql 2005 enterprise edition.
Qt Code:
  1. conn = QString::fromLocal8Bit("DRIVER={SQL SERVER};SERVER=192.168.10.96;DATABASE=master;Uid=sa;Pwd=[]");
  2. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MainDBConnection");
  3. db.setDatabaseName(conn);
  4. db.setUserName("sa");
  5. db.setPassword("[]");
To copy to clipboard, switch view to plain text mode 
thx!