本文介紹了PROE二次開發(fā)中pro/toolkit連接Access數(shù)據(jù)庫的一個例子。 JbzYr]k
_=B(jJZ
測試環(huán)境:WinXP sp2 + vc6.0 + MS Access 2000 7|PpAvMF
uxk&5RY
1.在工程的stdafx.h頭文件中引入ADO庫文件,如果系統(tǒng)不在C盤,請修改盤符 d+~c$(M)
udB:ys
#import "c:\program files\common files\system\ado\msado15.dll" \ L5%~H?K(
Y{Kpopst
rename_namespace("myado") \ jo=XxA
eJ)Bs20Q
rename ("EOF", "adoEOF") Vi`+2%4
94I8~Jj4
2.在要操作數(shù)據(jù)庫的類中加入數(shù)據(jù)庫指針,例中為對話框類CDlgData >#dNXH]9
H? N!F7s
myado::_ConnectionPtr m_pConnection; _6THyj$f
* b>W
3.在這個類中加入打開數(shù)據(jù)庫與關(guān)閉數(shù)據(jù)庫的成員函數(shù),并在對話框初始化時打開數(shù)據(jù)庫,在對話框關(guān)閉時關(guān)閉數(shù)據(jù)庫,如例子中的函數(shù)OpenDatabase、CloseDatabase、OnInitDialog DestroyWindow KL*ZPKG
{>OuxVl??k
4.操作表,如例子中的函數(shù)InitListBox。