VC6.0怎样连接ORACLE数据库啊

SKATE11 2012-12-17 10:00:50
用的是ORACLE 11g
在VC上写了个测试程序 连接代码如下
AfxOleInit();
m_pConnection.CreateInstance(__uuidof(Connection));
try //建立数据库连接
{
m_pConnection.CreateInstance(__uuidof(Connection));
m_pConnection->Open("Provider=OraOLEDB.Oracle.1;Password=tiger;User ID=scott;Data Source=pan;Persist Security Info=True","","",adModeUnknown);
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("数据库连接失败!\r\n错误信息:%s", e.ErrorMessage());
AfxMessageBox(errormessage);//return FALSE;
}
怎么连接不上啊
ORACLE 那边我什么都没动过 是不是还要设置配置什么啊 高人指教
...全文
233 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
SKATE11 2012-12-20
  • 打赏
  • 举报
回复
还有全面点的吗 比如说怎样设置oracle服务器这些
bustoy 2012-12-18
  • 打赏
  • 举报
回复

	::CoInitialize(NULL);
	
	try
	{
		_bstr_t bstrConn;
		char szConn[256];
		memset(szConn, '\0', 256);
		
		sprintf(szConn, "Provider=OraOLEDB.Oracle.1;" 
			"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=%s)(PORT=%d)))(CONNECT_DATA=(SERVICE_NAME=%s)));"
			"Persist Security Info=TRUE;"
			"User ID=%s;"
			"Password=%s;",
			pHostIP, nPort, 
			pDataSource, pUserID, pPassword);
		bstrConn = szConn;
		TESTHR(m_ptrDBConnection.CreateInstance(__uuidof(Connection)));
		TESTHR(m_ptrDBConnection->Open(bstrConn, "", "", adConnectUnspecified)); 	
		TESTHR(m_ptrCommand.CreateInstance(__uuidof(Command)));
		m_ptrCommand->ActiveConnection = m_ptrDBConnection;
		m_ptrCommand->CommandType = adCmdText;
		m_ptrCommand->Parameters->Refresh();
	}
	catch (_com_error &e)
	{
		m_ptrDBConnection = NULL;
		m_ptrCommand = NULL;
		AfxTrace("Error:At Line %d\n",__LINE__);
		AfxTrace("Code = %08lx\n", e.Error());
		AfxTrace("Meaning = %s\n", e.ErrorMessage());
		AfxTrace("Source = %s\n", (LPCSTR) e.Source());
		AfxTrace("Description = %s\n", (LPCSTR) e.Description());
		return E_UNEXPECTED;
	}
	return S_OK;

赵4老师 2012-12-18
  • 打赏
  • 举报
回复
OCI demo
Program Name                              Features Illustrated
cdemo81.c                                 Using basic SQL processing with release 8 and later functionality.
cdemo82.c                                 Performing basic processing of user-defined objects.
cdemocor.c                                Using complex object retrieval (COR) to improve performance.
cdemodr1.c,cdemodr2.c,cdemodr3.c          Using INSERT/UPDATE/DELETE statements with RETURNING clause used with basic datatypes, LOBs and REFs.
cdemodsa.c                                Describing information about a table.
cdemodsc.c                                Describing information about an object type.
cdemofo.c                                 Registering and operating application failover callbacks.
cdemolb.c                                 Create and insert LOB data and then read, write, copy, append and trim the data.
cdemolb2.c                                Writing and reading of CLOB/BLOB columns with stream mode and callback functions.
cdemolbs.c                                Writing and reading to LOBs with the LOB buffering system.
cdemobj.c                                 Pinning and navigation of REF object.
cdemorid.c                                Using INSERT, UPDATE, DELETE statements and fetches to get multiple rowids in one round-trip.
cdemoses.c                                Using session switching and migration.
cdemothr.c                                Using the OCIThread package.
cdemosyev.c                               Registering predefined subscriptions and specifying a callback function to be invoked for client notifications (for more information about Advanced Queuing, see Oracle Streams Advanced Queuing User’s Guide and Reference).
ociaqdemo00.c,ociaqdemo01.c,ociaqdemo02.c Advanced queuing.
cdemodp.c,cdemodp_lip.c                   Loading data with the direct path load functions.
cdemdpco.c                                Loading a column object with the direct path load functions.
cdemdpno.c                                Loading a nested column object with the direct path load functions.
cdemdpin.c                                Loading derived type (inheritance) - direct path.
cdemdpit.c                                Loading an object table with inheritance - direct path.
cdemdpro.c                                Loading a reference with the direct path load functions.
cdemdpss.c                                Loading SQL strings with the direct path load functions.
cdemoucb.c,cdemoucbl.c                    Using static and dynamic user callbacks.
cdemoupk.c,cdemoup1.c,cdemoup2.c          Using dynamic user callbacks with multiple packages.
cdemodt.c                                 Datetime and interval example.
cdemosc.c                                 Scrollable cursor.
cdemol2l.c                                Accesses LOBs using the LONG API.
cdemoin1.c                                Inheritance demo which modifies an inherited type in a table and displays a record from the table.
cdemoin2.c                                Inheritance demo to do attribute substitutability.
cdemoin3.c                                Inheritance demo that describes an object, inherited types, object tables, and a sub-table.
cdemoanydata1.c                           Anydata demo. Inserts and selects rows to and from anydata table.
cdemoanydata2.c                           Anydata demo. Creates a type piecewise using OCITypeBeginCreate() and then describes the new type created.
cdemosp.c                                 Session pooling.
cdemocp.c                                 Connection pooling.
cdemocpproxy.c                            Connection pooling with proxy functionality.
cdemostc.c                                Statement caching.
cdemouni.c                                Program for OCI UTF16 API.
nchdemo1.c                                Shows nchar implicit conversion feature and codepoint feature.
SKATE11 2012-12-17
  • 打赏
  • 举报
回复
寻求支援了 CSDN的高手们

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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