[C++][Connexion] Impossible de se connecter à ma base
Je n'arrive pas à connecter mon programme C++ à une base local en Postgres.
Voilà le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| //---------------------------------------------------------------------------
//
// Name: ConnexionDlg.cpp
// Author: Equipe Ouroboros
// Created: 12/01/2006 10:58:12
//
//---------------------------------------------------------------------------
#include "ConnexionDlg.h"
#include "libpq-fe.h"
#include "WxBitmapButtonConnexion_XPM.xpm"
//----------------------------------------------------------------------------
// ConnexionDlg
//----------------------------------------------------------------------------
// ....
// ...
/*
* WxBitmapButtonConnexionClick
*/
void ConnexionDlg::WxBitmapButtonConnexionClick(wxCommandEvent& event)
{
// traitement de vérification de login/Mot de passe
wxString login = WxEditLogin->GetValue();
wxString password = WxEditPassword->GetValue();
wxString tmp = "SELECT passwd FROM admin WHERE login = '" + login + "'";
PGconn *connect;
const char *conninfo = "host = localhost dbname = postgres user = postgres password = azerty"; /*Test est le nom de ma base*/
connect = PQconnectdb(conninfo);
//PGconn * connect = PQsetdbLogin("localhost","5432",NULL,NULL,"postgres","postgres","azerty");
//PGconn * connect = PQconnectdb();
if (PQstatus(connect) != CONNECTION_OK)
{
wxString tmp1 = PQerrorMessage(connect);
wxString error = "Connection impossible à la base :\n" + tmp1;
wxMessageBox(error, "Erreur!!" ,
wxOK | wxICON_ERROR);
}
PGresult * result = PQexec(connect, tmp);
//wxString nom = PQdb(connect);
if(result == NULL)
{
wxMessageBox("Login ou password incorrect!", "Erreur !" ,
wxOK | wxICON_ERROR);
}
else
Destroy();
} |
Et voici l'erreur:
http://img67.imageshack.us/img67/5519/erreur8ja.png