用vc,ado查看access数据库a是否存在表b,c的代码
2个回答
展开全部
可以的,看看adox中关于tables的帮助。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
与Access数据库连接
AfxEnableControlContainer();
AfxOleInit();
_ConnectionPtr m_pConncetion;
m_pConncetion.CreateInstance(__uuidof(Connection));
try
{
m_pConncetion->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=***.mdb","","",adModeUnknown);//数据库文件放在工程文件夹中
}
catch(_com_error e)
{
AfxMessageBox("数据库连接失败!");
return FALSE;
}
查询
_RecordsetPtr m_pRecordset;
int count;
_variant_t vIndex,vCount,;
m_pRecordset.CreateInstance(__uuidof(Recordset));
CString str;
m_pRecordset->Open("SELECT COUNT(*) FROM Book",theApp.m_pConncetion.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
vIndex=(long)0;
vCount=m_pRecordset->GetCollect(vIndex);
count=vCount.lVal;
浏览记录
m_pRecordset->MoveFirst();
m_pRecordset->MovePrevious();
m_pRecordset->MoveNext();
m_pRecordset->MoveLast();
CString m_strBookNo= (char*)_bstr_t(m_pRecordset->GetCollect("Bno"));
CString m_strBookName=(char*)_bstr_t(m_pRecordset->GetCollect("Bname"));
添加记录
m_pRecordset->AddNew();
m_pRecordset->PutCollect("Bno",_variant_t(m_strBookNo));
m_pRecordset->PutCollect("Bname",_variant_t(m_strBookName));
m_pRecordset->Update();
修改记录
m_pRecordset->PutCollect("Bno",_variant_t(m_strBookNo));
m_pRecordset->PutCollect("Bname",_variant_t(m_strBookName));
m_pRecordset->Update();
删除记录
m_pRecordset->Delete(adAffectCurrent);
AfxEnableControlContainer();
AfxOleInit();
_ConnectionPtr m_pConncetion;
m_pConncetion.CreateInstance(__uuidof(Connection));
try
{
m_pConncetion->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=***.mdb","","",adModeUnknown);//数据库文件放在工程文件夹中
}
catch(_com_error e)
{
AfxMessageBox("数据库连接失败!");
return FALSE;
}
查询
_RecordsetPtr m_pRecordset;
int count;
_variant_t vIndex,vCount,;
m_pRecordset.CreateInstance(__uuidof(Recordset));
CString str;
m_pRecordset->Open("SELECT COUNT(*) FROM Book",theApp.m_pConncetion.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
vIndex=(long)0;
vCount=m_pRecordset->GetCollect(vIndex);
count=vCount.lVal;
浏览记录
m_pRecordset->MoveFirst();
m_pRecordset->MovePrevious();
m_pRecordset->MoveNext();
m_pRecordset->MoveLast();
CString m_strBookNo= (char*)_bstr_t(m_pRecordset->GetCollect("Bno"));
CString m_strBookName=(char*)_bstr_t(m_pRecordset->GetCollect("Bname"));
添加记录
m_pRecordset->AddNew();
m_pRecordset->PutCollect("Bno",_variant_t(m_strBookNo));
m_pRecordset->PutCollect("Bname",_variant_t(m_strBookName));
m_pRecordset->Update();
修改记录
m_pRecordset->PutCollect("Bno",_variant_t(m_strBookNo));
m_pRecordset->PutCollect("Bname",_variant_t(m_strBookName));
m_pRecordset->Update();
删除记录
m_pRecordset->Delete(adAffectCurrent);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询