预备:(1)、引入ADO类 #import "c:program filescommon filessystemadomsado15.dll" 
  
  no_namespace 
  
  rename ("EOF", "adoEOF")
  
  (2)、初始化COM在MFC中可以用AfxOleInit();非MFC环境中用: 
  
  CoInitialize(NULL);
  
  CoUnInitialize();(3)#import 包含后就可以用3个智能指针了:_ConnectionPtr、_RecordsetPtr和_CommandPtr1.连接和关闭数据库 (1)连接 例子:连接Access数据库
  
  AfxOleInit();//初始化
  
  HRESULT hr;
  
  try
  
  {
  
  hr = m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象