0

I'm trying to connect to a postgreSQL database without configuring System DSN with ODBC, I've googled a lot and I've tried a lot of connection strings but they didn't work, maybe I'm doing something wrong. Here is one of the connection strings i've tried:

dbConnectionString = QString("Driver=PostgreSQLUnicode(x64)}| Server="+DBhost+"|Port=%1|Database="+dbname+"|Uid="+username+"|Pwd="+password+"|ByteaAsLongVarBinary=1").arg(port) db.setDatabaseName(dbConnectionString);

Any suggestion?

3
  • Working example without odbc Commented Jun 29, 2015 at 14:41
  • You don't need ODBC, it only adds a layer of indirection for no good reason. Qt can use most databases directly, without ODBC. Commented Jun 29, 2015 at 17:07
  • Thank both of you, now i can connect to database using QPSQL driver, but now all the prepare statement that i used with QODBC don't work. Can you tell me why? This is my code: ` qdb1.prepare("select * from function('c1',?,?,?,?,?,?);fetch all in c1"); qdb1.bindValue("0",iSensor); qdb1.bindValue("1",stGeom); qdb1.bindValue("2",stImage); qdb1.bindValue("3",stVideo); qdb1.bindValue("4",stDateFrom); qdb1.bindValue("5",stDateTo); qdb1.exec(); ` I'm sure that parameters are right. Commented Jun 30, 2015 at 8:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.