[求助]应用ADO 无法初始化 指针
<p>#include "StdAfx.h"<br/>#include "StdArx.h"</p><p>//-----------------------------------------------------------------------------<br/>// This is command 'LINK, by , , <br/>void asdklink()<br/>{<br/>#ifdef OARXWIZDEBUG<br/> acutPrintf ("\nOARXWIZDEBUG - asdklink() called.");<br/>#endif // OARXWIZDEBUG</p><p> // TODO: Implement the command<br/> ::CoInitialize(NULL);<br/> ADO::_ConnectionPtr connPtr;<br/> <br/> //AfxGetModuleState()->m_dwVersion = 0x0601; <br/> <br/> // HRESULT hr =connPtr.CreateInstance("ADODB.Connection");<br/> HRESULT hr =connPtr.CreateInstance(__uuidof(Connection));<br/> if(SUCCEEDED(hr))<br/> {<br/> acutPrintf("Create Instance SUCCEEDED!");<br/> return;<br/> }<br/> else<br/> {<br/> acutPrintf("Create Instance FAILED!");<br/> }<br/> CString strConn;<br/> strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\PipeData.mdb";</p><p> _bstr_t varConn(strConn);<br/> if (FAILED(connPtr->Open(varConn,"","",-1)))<br/> {<br/> acutPrintf("Can not open Database!");<br/> connPtr.Release();<br/> return;<br/> }<br/> ADO::_RecordsetPtr recdPtr;<br/> if (FAILED(recdPtr.CreateInstance("ADODB.Recordset")))<br/> {<br/> acutPrintf("recdPtr Create Instance failed!");<br/> return;<br/> }<br/> CString strSql;<br/> strSql="select *from (. AS a INNER JOIN . AS b ON a.起始点号=b.起点) INNER JOIN . AS c ON a.终止点号=c.终点";<br/> _variant_t varSql(strSql);<br/> //_variant_t varCon(strConn);<br/> if(FAILED(recdPtr->Open(varSql,connPtr.GetInterfacePtr(),ADO::adOpenDynamic,ADO::adLockOptimistic,ADO::adCmdText)))<br/> {<br/> acutPrintf("Open table failed!");<br/> recdPtr.Release();<br/> return;<br/> }<br/> else<br/> {<br/> acutPrintf("成功");<br/> }<br/> <br/> <br/>}</p><p>StdAfx.h已经引用了#import "C:\Program Files\Common Files\System\ado\msado15.dll" rename_namespace("ADO") rename("EOF","adoEOF") </p><p>BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)<br/>{ <br/> AfxOleInit();</p><p>}</p>[求助]应用ADO 无法初始化 指针
<p>不能初始化 _ConnectionPtr</p><p>请各位大师指教.</p> <p>困扰我很久了,希望那位高手给以指点。</p>
页:
[1]