1.使用VC/mfc,用代码建立能够使用的Access数据库文件(.mdb),怎么办?
2.如何判断一个Access数据库中是否含有指定表名(如:StudInfo)的表?

解决方案 »

  1.   

    用DAO或ADO接口判断表
    if exist tablename(记得有这样的SQL用法)
      

  2.   

    其实任何一本入门VC的书上都有,可以随便下一本看看。这里给出的代码和解释可能不全面。
    可以去www.vckbase.com看看那。ps 你的题目是什么意思?人有三急,不知道你是说哪一急 :)
      

  3.   

    1 Dao或者Adox可以新建Mdb文件, Ado不可以新建Mdb文件
    2 Ado得到所有数据表名称
    _RecordsetPtr  pRstSchema  = NULL;
    try
    {
    pRstSchema = theApp.m_pConnection->OpenSchema(adSchemaTables);

    while(!(pRstSchema->adoEOF))
    {
    _bstr_t table_name = pRstSchema->GetCollect("TABLE_NAME");
    _bstr_t table_type = pRstSchema->GetCollect("TABLE_TYPE");

    str = (char*)table_name; m_Combo.AddString(str);
    }

    pRstSchema->MoveNext();
    }
    if (pRstSchema->State == 1)
    {
    pRstSchema->Close();
    }
    }
    catch(_com_error *e)
    {
    e->ErrorMessage();
    //AfxMessageBox(e->ErrorMessage());
    }
    catch(...)
    {
    }

    if (pRstSchema->State == 1)
    {
    pRstSchema->Close();
    }