打开数据库连接
_ConnectionPtr m_pConn;
_RecordsetPtr m_pRs;
m_pConn.CreateInstance(__uuidof(Connection));
m_pRs.CreateInstance(__uuidof(Recordset));
//连接字符串在你的机器上可能不适用,自己试一下
CString str = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Data Source=ZHANGJIAN";
m_pConn->Open(_bstr_t(str),"","",-1);
_variant_t vFieldValue;
CString strFieldValue;
m_pRs=m_pConn->OpenSchema(adSchemaCatalogs);
包含字段名称CATALOG_NAME,DESCRIPTION,
列举m_pRs的所有_bstr_t(m_pRs->GetCollect("CATALOG_NAME"))就可以了