<html>
<P>con este script te podes conectar, esto es básico, vos le agregas el nivel de complejidad que necesitas.</P>
<P>saludos</P>
<P><BR>
#include <stdio.h><BR>
#include <libpq-fe.h><BR>
#include <iostream><BR>
#include <fstream></P>
<P>static void<BR>
salir(PGconn *psql)<BR>
{<BR>
PQfinish(psql);<BR>
exit(1);<BR>
}</P>
<P>int<BR>
main()<BR>
{</P>
<P>PGconn *psql;<BR>
PGresult *result;</P>
<P>int nFields;<BR>
int i,j;</P>
<P><BR>
psql = PQconnectdb("hostaddr = '10.20.182.13' port = '5432' dbname = 'apl_calden2' user = 'postgres' password = 'manager' conn<BR>
ect_timeout = '10'");<BR>
</P>
<P>if (PQstatus(psql) != CONNECTION_OK)<BR>
{<BR>
fprintf(stderr, "libpq error: PQstatus(psql) != CONNECTION_OK\n\n");<BR>
salir(psql);<BR>
}</P>
<P>result = PQexec(psql,"select * from empresa;");</P>
<P> nFields = PQnfields(result);</P>
<P> if (nFields != 0){<BR>
for (i = 0; i < nFields; i++)<BR>
printf("%-15s", PQfname(result, i));<BR>
printf("\n\n");</P>
<P><BR>
for (i = 0; i < PQntuples(result); i++)<BR>
{<BR>
for (j = 0; j < nFields; j++)<BR>
printf("%-15s", PQgetvalue(result, i, j));<BR>
printf("\n");<BR>
}</P>
<P> PQclear(result);<BR>
}</P>
<P>salir(psql);</P>
<P><BR>
}</P>
</html><BR><br><addr>------------------------------------------------------------------------<br>
<b><a href=http://free.internet.argentina.com/>Conectate a Internet Gratis de Argentina.Com</a></b><br>
</addr>
<br>
<center>
<a href=http://srvads.argentina.com/bs/adclick.php?n=a84973ad target=_blank>
<img src=http://srvads.argentina.com/bs/adview.php?what=zone:8&n=a84973ad border=0 alt=""></a>
</center>