连接不上PostgreSQL数据库

shanhengshu 2009-10-15 04:48:09
我是新手,刚刚接触PostgreSQL数据库,今天研究怎么去连接它弄了半天也没连上,请各位高手指点一下,我实在windows xp下,用VS2005的编译环境,我写的代码如下:

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
_ConnectionPtr m_pConnection=NULL;
HRESULT hr=m_pConnection.CreateInstance(__uuidof(Connection));
hr=m_pConnection->Open("Driver={PostgreSQL};Server=192.168.1.104;Port=5432;Database=Student Management","postgres","1234",adModeUnknown);
if(m_pConnection->State)
cout<<"数据库已连接!";

return 0;
}


编译能通过,在运行到红色语句时,弹出对话框 “Unhandled exception at 0x7c812a6b in 2.exe: Microsoft C++ exception: _com_error at memory location 0x0012fd0c..”

继续后,又弹出对话框 “Unhandled exception at 0x004126fd in 2.exe: 0xC0000005: Access violation reading location 0x00000000.”

并且无法继续了(我逐句运行调试的),不知道是哪里出了问题,期待高手的指点,先谢过了!!!
...全文
297 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chpLOVElgz 2012-07-02
  • 打赏
  • 举报
回复
我也是刚接触postgreSQL这个东东,我都纠结N久了,还是没连接上,老是出错。
shanhengshu 2009-10-16
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 nianzhang747 的回复:]
你系统c++能运行吗

有环境吗

问题应该不是sql

[/Quote]

有啊 当然能运行C++了,要不我怎么编译通过的啊
iisbsd 2009-10-16
  • 打赏
  • 举报
回复
你是不是也是新接触ADO啊?

nianzhang747 2009-10-15
  • 打赏
  • 举报
回复
你系统c++能运行吗

有环境吗

问题应该不是sql

56,912

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧