如何获取Access数据的所有表的名字
用ADO的方法
也就是说用程序列出数据库中的所有表。

解决方案 »

  1.   

    给一段vbs代码,翻译成VC就靠自己了 Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=xxx.mdb"
    Set rs = Server.CreateObject("ADODB.recordset") Set rs = conn.OpenSchema( 20 )

    do while not (rs.eof)

    '循环显示所有查询出的项,由于序号为0的第一项为Id,不必显示,所以从1开始遍历
    For i = 1 To rs.Fields.Count - 1
    Response.Write rs(i).Name & " : " & rs(i) & "<br>"
    Next

    Response.Write "<br>" & vbCrlf
    rs.Movenext
    loop

    rs.Close
    set rs = nothing

    conn.Close
    set conn = Nothing
      

  2.   

    conn.OpenSchema( 20 )
    是什么意思.
      

  3.   

    pRstSchema = theApp.m_pConnection->OpenSchema(adSchemaTables);//指?.? 所有的?.? while(!(pRstSchema->adoEOF))   //指针是否已经指向最后一条记录?
        {
    _bstr_t table_name = pRstSchema->Fields->GetItem("TABLE_NAME")->Value;//得到表的名称
    m_ListBox.AddString((char*)table_name);
    char pType[40];
    CString sTableName;               
    strcpy(pType, (char *)_bstr_t(pRstSchema->GetCollect("TABLE_TYPE")));
    if (!strcmp(pType, "TABLE"))         
                      m_ListBox.AddString((char*)(_bstr_t)pRstSchema->GetCollect("TABLE_NAME"));
    pRstSchema->MoveNext();

    }