[ILUG-Cochin.org] Postgresql Help

Saju M sajuptpm at gmail.com
Wed Apr 1 19:03:11 IST 2009


#include<stdio.h>
#include "/usr/include/libpq-fe.h"

void main()
{

PGconn *conn;
PGresult *res;
int id;
char name[20];
char *qur;

conn =
PQsetdbLogin("127.0.0.1","5432",NULL,NULL,"postgres","postgres",NULL);


  if(PQstatus(conn)==CONNECTION_OK)
  {
    printf("Connection Established\n\n");


   printf("Enter the ID: \n");
   scanf("%d",&id);
   printf("Enter the NAME: \n");
   scanf("%s",&name);
  *qur="insert into table values(id,name)";      <--------Error here, Why?
   res = PQexec(conn,qur);

    PQfinish(conn);
   }
   else
   {
     printf("Connection Failed\n");
   }


}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ilug-cochin.org/pipermail/mailinglist_ilug-cochin.org/attachments/20090401/497fb629/attachment-0001.html>


More information about the Mailinglist mailing list