谁能解决,分全给他(她)!需要把下面的代码调试出来,放在我能下载的地方!
环境: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;
}
环境: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;
}
解决方案 »
- 菜鸟举手~如何删除对话框程序中那两个默认的“确定”“取消”按钮!
- 有了BitmapBuf和BitmapInfo,怎么构建bitmap内存流?
- 要做一个模拟用户操作的程序,如何判断用户要点击的窗口中的控件已经准备好,因为很多情况下软件启动需要一定的时间
- 奇怪:VC2003,所有可编辑控件不能做中英文切换,一旦按ctrl+space或者ctrl+shit或者用鼠标选择输入法,程序就没响应了?
- 问个xml解析结点的问题
- 按钮对象实现功能的变换
- 多个窗口的数据传递问题!!!急,在线等。
- SQLConfigDataSource函数问题
- 我知道字符串“winword”,但是如何通过CreateProcess 把他启动起来
- 请教:在广域网中使用winsock传输大型文件该用什么协议?谢谢
- 关于控件ID 急 在线等
- 请教:关于图片生成的ActiveX的问题,请指教
Linking...
error LNK2001:unresolved external symbol _PQfinish