本文介紹了PROE二次開發(fā)中pro/toolkit連接Access數(shù)據(jù)庫的一個例子。 H?_wsh4J
$KVCEe!X
測試環(huán)境:WinXP sp2 + vc6.0 + MS Access 2000 LO;?#e7
NmA6L+
1.在工程的stdafx.h頭文件中引入ADO庫文件,如果系統(tǒng)不在C盤,請修改盤符 9i46u20
P,rD{ 0~
#import "c:\program files\common files\system\ado\msado15.dll" \ #9glGPR(
MW2{w<-]7
rename_namespace("myado") \ K=Z.<f
4;2
rename ("EOF", "adoEOF") - i#Kpf
z5J$".O`
2.在要操作數(shù)據(jù)庫的類中加入數(shù)據(jù)庫指針,例中為對話框類CDlgData &0`i(l4]l
7Ucq(,\./
myado::_ConnectionPtr m_pConnection; W6s-epsRmT
Jr=XVQ(F
3.在這個類中加入打開數(shù)據(jù)庫與關閉數(shù)據(jù)庫的成員函數(shù),并在對話框初始化時打開數(shù)據(jù)庫,在對話框關閉時關閉數(shù)據(jù)庫,如例子中的函數(shù)OpenDatabase、CloseDatabase、OnInitDialog DestroyWindow c2u*<x
$-p9cyk
4.操作表,如例子中的函數(shù)InitListBox。