刚开始学习C++通过ADO连接数据库,参考了网上的资料,写了如下代码, 
编译可以通过,运行时每次出现的是“error 3”,请高手指点一下! 
谢谢! 
#include <iostream.h>
#include <stdio.h>
#include <ICRSINT.H>
#import "D:\VC\c_ado\Debug\MSADO15.DLL"  no_namespace rename("EOF", "adoEOF")
void main()
{
CoInitialize(NULL);
//AfxOleInit();
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection));
if(FAILED(hr))
{
cout<<"error 1!"<<endl;
return;
}
_bstr_t strConnect="Driver={sql server};server=MICROSOF-37ED1B;uid=;pwd=;database=stockShouPJ"; 
//connecting to the database server now:
try{pMyConnect->Open(strConnect,"","",NULL);}
catch (_com_error &e)
{
cout<<"error 2!"<<endl;
//::MessageBox(NULL,e.Description(),"警告",MB_OK │ MB_ICONWARNING);
} _RecordsetPtr m_pRecordset;
if(!FAILED(m_pRecordset.CreateInstance( __uuidof( Recordset ))))
{
cout<<"error 3!"<<endl;    //运行时在此处出现错误!
//m_pDoc->m_initialized=FALSE;
return;
} try{
m_pRecordset->Open(_variant_t("mytable"),
_variant_t((IDispatch *)pMyConnect,true), adOpenKeyset,
adLockOptimistic, adCmdTable);
}
catch (_com_error &e)
{
cout<<"error 4!"<<endl;
//::MessageBox(NULL,"无法打开mytable表。","提示",MB_OK │ MB_ICONWARNING);
}
}