AfxOleInit();    HRESULT hr;
    hr=0;
try
{
    _ConnectionPtr pConn(__uuidof(Connection));
    if(SUCCEEDED(hr))
{
pConn->Open("driver={SQL Server};server=localhost;uid=test;pwd=123456;database=test","","",NULL);
        if(SUCCEEDED(hr)){
AfxMessageBox("test is good");
hr=pConn->Execute((_bstr_t)"restore database test from disk='D:\wwwroot\mssql_bak\test.bak' with move 'test_data' to 'D:\test.mdf',move 'sq_idcczlz_log' to 'D:\test.ldf'",NULL,adCmdText);
        if(SUCCEEDED(hr)){
           AfxMessageBox("备份成功");
}
}
}
}
catch(_com_error e)
{
  CString str1;
  str1.Format("连接数据库失败,原因为:%s",e.ErrorMessage());
  AfxMessageBox(str1); }