I'm struggling to get a connection using QtSql. The problem is that my type of connection is a "SQLOLEDB", and I can only find ODBDC examples... Please any help would be so much appriciated! Thanks in advice!
connection_string = ("Provider=SQLOLEDB;Data Source=XXXX;Initial Catalog=XXXX;User Id=XXXX;Password=XXXX")
db = QSqlDatabase().addDatabase("???", connection_string)
db.open()
Should I use this template?
db = QSqlDatabase.addDatabase("QODBC")
db.setHostName("XXXX")
db.setPort(1433)
db.setDatabaseName("XXXX")
db.setUserName("XXXX")
db.setPassword("XXXX")
ok = db.open()
Finally I've managed to connect to the server using a DSN like this:
Before you must configure a ODBC DSN in your PC using ODBC Windows Manager, and get it to connect to your database. Comments:
Hope it helps anyone!