CSV的导出,谁能给我点资料啊。我是完全不懂得阿。
有两种方法的参数,一种是一个类作为参数,一个是传入一个sql语句这种的。请教阿!!!!!!!!!!!!

解决方案 »

  1.   

    导出一个CSV文件阿。难道就没有人知道吗????
      

  2.   

    导出一个CSV文件,难道就没有人知道吗。希望达人能够教教我啊。
      

  3.   

    //strPath:csv文件的所在目录和csv文件名,如"C:\temp\123.csv"
    _ConnectionPtr CFMCSApp::OpenDataBaseConnection(CString strPath)
    {
    CString strConn;
    //CIniFile file("DC_GPSServer.ini");
    strConn.Format("Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=%s;Extensions=asc,csv,tab,txt;Persist Security Info=False",strPath);
    BSTR bstrConn = strConn.AllocSysString();

    _ConnectionPtr pConn;

    try
    {
    HRESULT hr;
    pConn.CreateInstance(__uuidof(Connection));
    pConn->ConnectionString = bstrConn;
    pConn->ConnectionTimeout = 0;
    hr = pConn->Open(_T(""), // privder and data source
     _T(""),       //user name of db
     _T(""),            //password of user
     adOpenUnspecified  //Does not specify the type of cursor.
     );
    if( FAILED(hr))
    {
    ::SysFreeString(bstrConn);
    // LogInfoTime("打开数据库连接失败");
    return NULL;
    }
    }
    catch(_com_error &e)
    {
    ::SysFreeString(bstrConn); _bstr_t bstrDescription(e.Description());
    CString msg;
    msg.Format("Description = %s", (LPCSTR) bstrDescription);
    MessageBox(NULL,msg,m_strAppTitle,MB_OK);
    return NULL;
    }
    ::SysFreeString(bstrConn);
    return pConn;
    }_RecordsetPtr CFMCSApp::DB_GetRecordset(_ConnectionPtr pConn,CString strSQL)
    {
    if(pConn==NULL)
    {
    MessageBox(NULL,_T("The Connection to DB is invalid!"),m_strAppTitle,MB_OK);
    return NULL;
    }
    HRESULT hr;
    BSTR bstrSQL;
    _RecordsetPtr  pRstRet = NULL;

    bstrSQL = strSQL.AllocSysString();
    try
    {
    pRstRet.CreateInstance(__uuidof(Recordset));
    hr = pRstRet->Open(bstrSQL, _variant_t((IDispatch *) pConn, 
                true), adOpenStatic/*adOpenDynamic*/, adLockOptimistic, adCmdText);
    }
    catch(_com_error &e)
    {
    _bstr_t bstrDescription(e.Description());
    //MessageBox(NULL,(LPCSTR)bstrDescription,m_strAppTitle,MB_OK);
    // LogComError(e);
    return NULL;
    }
    ::SysFreeString(bstrSQL); if( FAILED(hr))
    {
    // LogInfoTime("执行SQL语句错误,SQL:%s", strSQL);
    return NULL;
    }

    return pRstRet;
    }
    //赶紧给我分吧!!!