VB和ACCESS数据库文件相连

来源:百度知道 编辑:UC知道 时间:2024/05/16 05:36:21
如何在VB程序中建立与access数据库文件*.mdb文件的连接(请详细写出代码);如何在vb程序界面实现进行查询(对.mdb文件中的表的某一字段如:ID)~
谢谢高手回答~ 没有代码,就不用回答了..tks~~~

为Access创建Connection的代码如下:
dim dcGame as new adodb.connection
dcgame.cursorLocation = aduseclient
dcgame.open "PROVIDER = Microsoft.Jet.Oledb.3.51;Data Source= c:\game.mdb;"

dim cmd as new adodb.command
'在数据库中执行操作.
cmd.commandtext="Delete * from fighter")
cmd.commandType=adCmdText
set cmd.activeConnection = dcgame
cmd.execute

'打开数据集
dim gamerec as new adodb.recordset
dim cmd as new adodb.command
cmd.commandtext="Select * from fighter")
cmd.commandType=adCmdText
set cmd.activeConnection = dcgame (前边有定义)
set gamerec=cmd.execute