大家好。我是新手,剛開始學習C++ builder,有一個問題請教大家,麻煩指點一下,小弟先謝謝了。
有一個Access的資料庫,表table1,表里有兩列name,password.
請問我如何能讀取出表中的值呢?
我嘗試寫的程式如下,
Variant theDAO;
Variant theDB;
Variant theTable;
theDAO=Variant::CreateObject("DAO.DBEngine.36");
theDB=theDAO.Exec(Function("OpenDatabase") << "d:1.MDB");
theTable=theDB.Exec(Function("OpenRecordSet") << "table1");
while(bool(theTable.Exec(PropertyGet("EOF")))==false)
{
...
theTable.Exec(Procedure("MoveNext"));
}
theTable.Exec(Procedure("Close"));
就是回圈里如何寫,能讀出來每條記錄中每個列的值呢?
uj5u.com熱心網友回復:
你不能用adoquery控制元件嗎uj5u.com熱心網友回復:
直接用ado或bde或dbexpress組件很簡單方便uj5u.com熱心網友回復:
Variant theDAO;Variant theDB;
Variant theTable;
theDAO=Variant::CreateObject("DAO.DBEngine.36");
theDB=theDAO.Exec(Function("OpenDatabase") << "d:1.MDB");
theTable=theDB.Exec(Function("OpenRecordSet") << "table1");
while(bool(theTable.Exec(PropertyGet("EOF")))==false)
{
theTable.Exec(Function("欄位名"));
theTable.Exec(Procedure("MoveNext"));
}
theTable.Exec(Procedure("Close"));
uj5u.com熱心網友回復:
DAO是微軟官方在10年前(或許更早)就確定放棄的東西了。。。樓主用2樓的方法吧。。。。
uj5u.com熱心網友回復:
用ADO控制元件——轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/114439.html
標籤:數據庫及相關技術
上一篇:thinkphp 比RBAC更好的權限認證方式(Auth類認證)
下一篇:c++順序查找,的一些問題
