1

I am currently using postgresql 14.7 and QT5.8.0. When i enter the command "postgres -V" or "psql -V" it both shows 14.7. Hence when i try to use VS2015 and run my code. It managed to establish connection to the database but in the console it keeps on giving this message whenever i execute the console application. "It gave me this error saying "the server version of this postgresql is unknown falling back to the client version" Is there any way to resolve this? Below is the following code.

#include <QtSql>
#include <QApplication>
#include <cstdlib>
#include <iostream>
int main()
{   
FILE* stream = _popen("pg_config --version", "r");
char output[128];
fgets(output, sizeof(output), stream);

std::cout << "PostgreSQL version: " << output << std::endl;
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("localhost");
db.setDatabaseName("test");
db.setUserName("testtt");
db.setPassword("password");
bool ok = db.open();
qDebug() << ok;
qDebug() << db.connectionName();
qDebug() << db.contains();
    return 0;
}

0 Answers0