如题?!

解决方案 »

  1.   

    使用程序建立数据源,给你段代码
    CString sPath;
    GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
    sPath.ReleaseBuffer ();
    int nPos;
    nPos=sPath.ReverseFind ('\\');
    sPath=sPath.Left (nPos);
    CString lpszFile = sPath + "\\ip.mdb"; char* szDesc;
    int mlen;
    szDesc=new char[256];
    sprintf(szDesc,"DSN=%s? DESCRIPTION=TOC support source? DBQ=%s? FIL=MicrosoftAccess? DEFAULTDIR=%s?? ","ip",lpszFile,sPath);
    mlen = strlen(szDesc);
      for (int i=0; i<mlen; i++)
      {
    if (szDesc[i] == '?')
      szDesc[i] = '\0';
      }
    //if(FALSE==SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)\0","DSN=AbbDBQ=lpszFileDEFAULTDIR=sPath\0"))
    //if(FALSE==SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)\0","DSN=Abb\0DBQ=lpszFile\0DEFAULTDIR=sPath\0\0"))
    if (FALSE == SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)\0",(LPCSTR)szDesc))
    {
    AfxMessageBox("创建数据源失败,请手工创建!DSN为IP,数据库为ACCESS类型,文件名为IP.MDB!");
    }else
    {
    if(IDYES==MessageBox("创建数据源创建成功!现在启动分析程序?","提示信息",MB_YESNO))
    {
    CString Command="EMAILANALYZER.EXE";
    int nRes=WinExec(Command,SW_SHOWNORMAL);
    } }