打开.dbf后,怎么实现表的spl查询,选择等  
或者能不能打开整个数据库,用嵌入式的spl查询

解决方案 »

  1.   

    用的是vfp的数据库!
    CString strCommand;
    strCommand = "SELECT * FROM pt WHERE pno="+ strItem;
    m_pCommand.CreateInstance("ADODB.Command");
    m_pCommand->ActiveConnection = theApp.m_pConnection; // 将库连接赋于它
    m_pCommand->CommandText = _bstr_t(strCommand);
    m_pPtRecord = m_pCommand->Execute(NULL, NULL,adCmdText);//在这里出错!
      

  2.   

    file->new win32 console project.empty project.add vfp.cpp
    #include <windows.h>
    #include <stdio.h>
    #import "c:\Program Files\Common Files\System\ADO\msado20.tlb" \
        no_namespace rename("EOF", "EndOfFile")
    void PrintProviderError(_ConnectionPtr pConnection)
    {
        ErrorPtr    pErr  = NULL;
        if( (pConnection->Errors->Count) > 0)
        {
            long nCount = pConnection->Errors->Count;        
            for(long i = 0;i < nCount;i++)
            {
                pErr = pConnection->Errors->GetItem(i);
                printf("\t Error number: %x\t%s", pErr->Number,pErr->Description);
            }
        }
    }
    void main()
    {
    if(FAILED(::CoInitialize(NULL)))
            return ;
    _ConnectionPtr  pConnection    = NULL;
    _bstr_t strConnection = TEXT("Driver={Microsoft dBASE Driver (*.dbf)};DBQ=C:\\; DriverID=533;");
    try
    {

    _RecordsetPtr  pRstSchema  = NULL;
    _CommandPtr pCommand=NULL;
    pConnection.CreateInstance(__uuidof(Connection));
    pConnection->Open (strConnection, "", "", -1);
    pCommand.CreateInstance (__uuidof(Command));
    pRstSchema.CreateInstance (__uuidof(Recordset));
    _bstr_t sqltext="select * from jck98 ";
    pCommand->ActiveConnection =pConnection;
    pCommand->CommandText =sqltext;
    pCommand->CommandType=adCmdText; pRstSchema = pCommand->Execute (NULL,NULL,adCmdText);
    _variant_t filed[17];
    _bstr_t filedname[17];
        while (!pRstSchema->EndOfFile )
    {
    long kk=pRstSchema->GetFields ()->GetCount ();
    for (long uu=0;uu<kk;uu++)
    {
    filedname[uu]=pRstSchema->GetFields ()->GetItem ((_variant_t)uu)->GetName ();
    filed[uu]=pRstSchema->GetCollect (filedname[uu]); 
    }   
    pRstSchema->MoveNext ();
    }  
            pRstSchema->Close();
            pConnection->Close();
    }
    catch(...)
    {
    PrintProviderError(pConnection);
    }
    ::CoUninitialize();
    }
      

  3.   

    my dbf name is c:\jck98.dbf