关于ADO中间层的问题 我如何通过COM将ADO获取的结果集传递给客户端,敬请指教. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ADO是OLEDB的COM封装,注意传输量对分布系统的影响声明[out,retval]IDispatch **pRSSTDMETHODIMP CGetCurrData::ReadData(BSTR name, BSTR pwd, BSTR dsn, BSTR sel, BSTR sel_table, BSTR sel_from, BSTR sel_where, int sign, IDispatch **pRS){ AFX_MANAGE_STATE(AfxGetStaticModuleState()) // TODO: Add your implementation code here _bstr_t temp; _bstr_t strSQL; if(sign==0) { strSQL=sel; } else { temp="SELECT "; temp+=sel_table; temp+=" FROM "; temp+=sel_from; if(sel_where==L"") { temp+=" WHERE "; temp+=sel_where; } strSQL=temp; } HRESULT hr; _RecordsetPtr pORS; _ConnectionPtr pConn; try{ pConn.CreateInstance(__uuidof(Connection)); pORS.CreateInstance(__uuidof(Recordset)); hr=pConn->Open(dsn,name,pwd,-1); if(FAILED(hr)) _com_raise_error (hr); pORS->CursorLocation = adUseClient; pORS->Open(_variant_t(strSQL),(IDispatch*)pConn,adOpenStatic, adLockReadOnly,adCmdText); if (FAILED(hr)) _com_raise_error (hr); }catch(_com_error &e) { if (m_spObjectContext != NULL) m_spObjectContext->SetAbort(); return e.Error(); }// pORS->putref_ActiveConnection(NULL); *pRS=(IDispatch *)pORS.Detach(); if (m_spObjectContext != NULL) m_spObjectContext->SetComplete(); return S_OK;} 什么函数可以启动现有的服务 模板类编译不通过 如何重载OnOpenDocument ,OnSaveDocument 与自定义文件 新手提问,DLL导出类时候的报错,请大家指教,谢谢 怎么获取一个汉字的UNICODE编号? 如何调用带输出参数的存储过程 新手的问题 VC的SDK编程,在主窗口中加载资源文件中菜单,预编译能通过,为何不能运行....高分求解 奇怪的用法:#include <set>和#include <map> 请教大侠: 急,怎么能获得屏幕的CRect? 窗口问题!
声明[out,retval]IDispatch **pRSSTDMETHODIMP CGetCurrData::ReadData(BSTR name, BSTR pwd, BSTR dsn,
BSTR sel, BSTR sel_table, BSTR sel_from,
BSTR sel_where, int sign, IDispatch **pRS)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()) // TODO: Add your implementation code here
_bstr_t temp;
_bstr_t strSQL;
if(sign==0)
{
strSQL=sel;
}
else
{
temp="SELECT ";
temp+=sel_table;
temp+=" FROM ";
temp+=sel_from;
if(sel_where==L"")
{
temp+=" WHERE ";
temp+=sel_where;
}
strSQL=temp;
}
HRESULT hr;
_RecordsetPtr pORS;
_ConnectionPtr pConn; try{ pConn.CreateInstance(__uuidof(Connection)); pORS.CreateInstance(__uuidof(Recordset)); hr=pConn->Open(dsn,name,pwd,-1);
if(FAILED(hr)) _com_raise_error (hr);
pORS->CursorLocation = adUseClient;
pORS->Open(_variant_t(strSQL),(IDispatch*)pConn,adOpenStatic,
adLockReadOnly,adCmdText);
if (FAILED(hr)) _com_raise_error (hr); }catch(_com_error &e)
{
if (m_spObjectContext != NULL) m_spObjectContext->SetAbort();
return e.Error();
}
// pORS->putref_ActiveConnection(NULL);
*pRS=(IDispatch *)pORS.Detach();
if (m_spObjectContext != NULL) m_spObjectContext->SetComplete();
return S_OK;
}