請教大神:MFC如何連接Access資料庫并進,增添洗掉,查詢,更改操我作?需要具體的操作程序,萬分感謝!
uj5u.com熱心網友回復:
VS2013 MFC連接Access資料庫(ADO)詳細版實體操作(含Combo Box讀取資料庫內容,附原始碼)uj5u.com熱心網友回復:
1、用ADO建立鏈接字串,鏈接access資料庫。具體操作見1樓版主推薦的,非常詳細。
2、對資料庫中表的資料的查、刪、增、改都是采用SQL陳述句實作的,然后采用ADO發送和執行SQL陳述句即可。
例如
查:theApp.sqlcmd.Format(_T("SELECT * from Users"));//即可查詢到Users表中的所有欄位的記錄。
刪:sqlcmd = _T("Delete from Users where [UserName] = '") + m_strUserName + _T("'");
增: sqlcmd = _T("insert into Users (UserName) values('");
sqlcmd += m_strUserName;//UserName
sqlcmd += _T("')");
改: theApp.pRecordset->MoveFirst();
theApp.pRecordset->Move(m_iCurrentIndex);
theApp.pRecordset->PutCollect("UserPwd", _variant_t(m_strUserPwd));
theApp.pRecordset->Update();
需要學習SQL命令,ADO操作指令,需要注意每個表的欄位及型別。
學習需要勤動手測驗,沒有捷徑。
uj5u.com熱心網友回復:
謝謝您!我是第一次接觸SQL,對命令太不熟悉,還回去得學相關習下知識!轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/38816.html
標籤:基礎類
