to plug
i'm facing problem to connect to postgresql via c language the situation 
as follows
after making successful connection and terminating the software if i try 
making connection with wrong password the postgresql does not refuse 
making the connection at all and still making the connection

does you know what is the problem please can you help in that
thanks in advance
hatem gamal

###########################################
# this file named : pgsql.c
###########################################
#include <stdio.h>
#include <libpq-fe.h>
#include "tools.h"

int main( )
{
   PGconn *c=ConnectDB();
  CloseConn(c);
    return 0;
}

###########################################
# this file named : tools.h
###########################################
#include <libpq-fe.h>
PGconn *ConnectDB()
{
  PGconn *conn = NULL;

  // Make a connection to the database
  conn = PQconnectdb("hostaddr='127.0.0.1' port='5432' user='test' 
password='test22'  dbname=contact ");

  // Check to see that the backend connection was successfully made
    if (PQstatus(conn) != CONNECTION_OK)
    {
        printf("Connection to database failed\n");
    }
    else
    {

        printf("Connection to database - OK\n");
     }

  return conn;
}


void CloseConn(PGconn *conn)
{
    PQfinish(conn);   
}


/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to