X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E9229D1B46D for ; Thu, 11 Dec 2003 02:51:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62388-03 for ; Wed, 10 Dec 2003 22:50:42 -0400 (AST) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by svr1.postgresql.org (Postfix) with ESMTP id 60F98D1B471 for ; Wed, 10 Dec 2003 22:50:37 -0400 (AST) Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AUGuW-0004iq-00 for ; Thu, 11 Dec 2003 03:50:40 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-admin@postgresql.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AUGoG-0004gN-00 for ; Thu, 11 Dec 2003 03:44:12 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AUGoG-0001fu-00 for ; Thu, 11 Dec 2003 03:44:12 +0100 From: Stephen Powell Subject: Re: error in code Date: Thu, 11 Dec 2003 12:57:44 +1100 Lines: 48 Message-ID: References: <1071033961.1264.7.camel@chi> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (windows-nt) Hamster/2.0.4.0 Cancel-Lock: sha1:nHc1k7Sg06rH8Jnb0i5rhBHhBHs= X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/149 X-Sequence-Number: 11657 On 10 Dec 2003, ashok@kalculate.com wrote: > I written a code [...] Checking for errors is good: # include # include # include int main() { PGresult *result = NULL; PGconn *conn = NULL; int feild; printf("successful"); conn = PQconnectdb ("ashok"); if (!conn || CONNECTION_BAD == PQstatus(conn)) { fprintf(stderr, "Connection to database failed.\n"); fprintf(stderr, "%s", PQerrorMessage(conn)); exit(EXIT_FAILURE); } result = PQexec (conn, "select * from bill"); if (!result || PGRES_TUPLES_OK != PQresultStatus(result)) { fprintf(stderr, "select command returned no tuples\n"); fprintf(stderr, "%s", PQerrorMessage(conn)); exit(EXIT_FAILURE); } feild = PQntuples (result); printf("%d",feild); PQclear (result); PQfinish (conn); printf("hello"); return EXIT_SUCCESS; } > when i run the a.out it give nothing. Not even "successful" or "hello" from the printfs? > plz help me. Download the programmers manual from here -- Stephen Powell