vb怎样调用自己做好的access2007的数据?
1个回答
展开全部
看你用什么控件
--------------------------------------
VBS都能调用
Dim Conn
Dim DBPath
Set conn=createobject("adodb.connection")
DBPath = "数据库绝对路径"
Conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Set conn=createobject("adodb.recordset")
sql="select * from 表"
rs.open sql conn,1,1
rs("字段")
rs.close
--------------------------------------------------
gridData+adodc控件
dbConnectStr = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & DatePath & ";DefaultDir=" & App.Path & "\" & ";"
dbStr = "SELECT * FROM 表"
Set gridData.DataSource = Nothing
Adodc1.RecordSource = ""
Adodc1.ConnectionString = ""
Adodc1.ConnectionString = dbConnectStr
Adodc1.RecordSource = dbStr
Adodc1.Refresh
If Adodc1.Recordset.Fields.Count = 0 Then
gridData.ClearFields
Else
Set gridData.DataSource = Adodc1.Recordset
gridData.ClearFields
gridData.ReBind
End If
--------------------------------------
VBS都能调用
Dim Conn
Dim DBPath
Set conn=createobject("adodb.connection")
DBPath = "数据库绝对路径"
Conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Set conn=createobject("adodb.recordset")
sql="select * from 表"
rs.open sql conn,1,1
rs("字段")
rs.close
--------------------------------------------------
gridData+adodc控件
dbConnectStr = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & DatePath & ";DefaultDir=" & App.Path & "\" & ";"
dbStr = "SELECT * FROM 表"
Set gridData.DataSource = Nothing
Adodc1.RecordSource = ""
Adodc1.ConnectionString = ""
Adodc1.ConnectionString = dbConnectStr
Adodc1.RecordSource = dbStr
Adodc1.Refresh
If Adodc1.Recordset.Fields.Count = 0 Then
gridData.ClearFields
Else
Set gridData.DataSource = Adodc1.Recordset
gridData.ClearFields
gridData.ReBind
End If
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询