连接ACCESS代码:
AfxOleInit();
m_pConnection.CreateInstance(__uuidof(Connection));
try                 
{
// 打开本地Access库Demo.mdb
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据输入表D.MDB","","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox("数据库连接失败,请确认本程序数据库(后缀名为mdb)是否在当前路径下!");
this->CloseWindow();
CWnd* pw=AfxGetMainWnd();
if(pw!=NULL)
{
pw->PostMessage(WM_CLOSE,0,0);
}
return FALSE;
}  
_RecordsetPtr pHandlerRecordset;
pHandlerRecordset.CreateInstance(__uuidof(Recordset));
try
{
pHandlerRecordset->Open("SELECT * FROM js_MCGS", // 此处可能有错误!!!但捕捉不到 !! m_pConnection.GetInterfacePtr(),  // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
pHandlerRecordset->Close();
    pHandlerRecordset.Release();
    pHandlerRecordset = NULL;
m_pConnection->Close();
m_pConnection=NULL;
this->CloseWindow();
CWnd* pw=AfxGetMainWnd();
if(pw!=NULL)
{
pw->PostMessage(WM_CLOSE,0,0);
}
return FALSE;
}
_variant_t var;
CString strName="";
try
{
if(!pHandlerRecordset->BOF)
pHandlerRecordset->MoveLast();
else
{
AfxMessageBox("当前数据库无相应表格数据,请成功确认保存后再尝试!");
pHandlerRecordset->Close();
        pHandlerRecordset.Release();
        pHandlerRecordset = NULL;
    m_pConnection->Close();
    m_pConnection=NULL;
    this->CloseWindow();
    CWnd* pw=AfxGetMainWnd();
    if(pw!=NULL)
{
    pw->PostMessage(WM_CLOSE,0,0);
}
    return FALSE;
}
//每行分别放入时间和数值数组

    char str1[4];
    CString str2="";
    char *str3=str1;
    for(int j=0;j<=20;j++)
{
    itoa(j,str3,10);
    str2="j"+(CString)str3;
    var = pHandlerRecordset->GetCollect((_variant_t)str2);
    if(var.vt != VT_NULL)
    test_a[j]=atof((LPCSTR)_bstr_t(var));
    if(j==0)
{
    test_b[j]=0;
}
    else
{
    if(test_a[j]==0)
{
    zpos=j;
    break;
}
    test_b[j]=test_b[j-1]+test_a[j];
}
}
    x_step=test_b[j-1];
}
    pHandlerRecordset->Close();
}
    catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
pHandlerRecordset->Close();
    pHandlerRecordset.Release();
    pHandlerRecordset = NULL;
m_pConnection->Close();
m_pConnection=NULL;
this->CloseWindow();
CWnd* pw=AfxGetMainWnd();
if(pw!=NULL)
{
pw->PostMessage(WM_CLOSE,0,0);
}
return FALSE;
}