(1)怎样用recordsetPtr打开一个表
(2)ADO中,如何得到一个表的所有字段名和字段的数据类型?

解决方案 »

  1.   

    m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\vctest\\AdoTest\\Debug\\Mydb.mdb;Persist Security Info=False","","",0);
    CString strSQL = "Select * from REALdata";
    BSTR bstrSQL = strSQL.AllocSysString();
    m_pRecordset->Open(bstrSQL,(IDispatch*)m_pConnection,adOpenDynamic,adLockOptimistic,adCmdText); int lCount = m_pRecordset->Fields->Count;
    for(int i=0;i<lCount;i++)
    {
    CString bb;
    _variant_t TheValue;
    //TheValue = _variant_t(i,VT_I4);
    TheValue.vt = VT_I4;
    TheValue.lVal = i;
    bb=(LPCTSTR)m_pRecordset->Fields->GetItem(TheValue)->GetName();
    AfxMessageBox(bb);
    }
    通过如下方法,可以得到字段的名称,类型等相关信息
    bb=(LPCTSTR)m_pRecordset->Fields->GetItem(TheValue)->GetName();
    如有问题,可以给我发消息
      

  2.   


    看这吧
    http://www.vckbase.com/document/viewdoc.asp?id=496