谁能解决,分全给他(她)!需要把下面的代码调试出来,放在我能下载的地方!
环境:Windows XP ,VC6.0 ,PostGre8.3.1#include "stdafx.h"
#include <libpq-fe.h>
void verifyCCon()
{
const char *conninfo;
int i;
PGconn *conn;
PGresult *res;
conninfo = "host=localhost hostaddr=127.0.0.1 port=5432 dbname=postgres user=postgres password=123456";
printf("before connect\n");
/* 和数据库建立链接 */
conn = PQconnectdb(conninfo);
/*
* 检查一下与服务器的连接是否成功建立
*/
if (PQstatus(conn) != CONNECTION_OK)
{printf("fail\n");
PQerrorMessage(conn);
return;
}
else
{
printf("success\n");
}PQexec(conn,"create table test1 (name char(20),age int4);");
PQexec(conn,"insert into test1 values ('cjm',10);");
PQexec(conn,"insert into test1 values ('eight',20);");
PQexec(conn,"insert into test1 values ('linuxaid',30);");
printf("all the date is:\n");
res = PQexec(conn, "select * from test1;");
for (int i = 0; i < PQntuples(res); i++)
{
for (int j = 0; j < PQnfields(res); j++)
{
printf("%15s", PQgetvalue(res, i, j));
}printf("\n");
}
PQclear(res);
printf("\n\n");
PQfinish(conn);}int _tmain(int argc, _TCHAR* argv[])
{
verifyCCon();return 0;
}