ADO与ADOX示例
时 间:2018-06-14 16:04:52
作 者:萤火虫 ID:66752 城市:大理
摘 要:ADO与ADOX示例
正 文:
ACCESS引用ADO 运用OLE DB技术存取数据
VBA给列表框值:
Option Compare Database
Private Sub Form_Load()
Dim cnnDB As New ADODB.Connection
Dim RSTobJECT As New ADODB.Recordset
Dim lbxEmployee As ListBox
Dim strList As String
Set lbxEmployee = Me![员工清单]
Set cnnDB = CurrentProject.Connection
RSTobJECT.Open "tb员工", cnnDB
strList = "姓名;职称;出生日期;"
With RSTobJECT
Do Until .EOF
strList = strList & !姓名 & ";" & !职称 & ";" _
& !出生日期 & ";"
.MoveNext
Loop
.Close
End With
lbxEmployee.RowSource = strList
Set RSTobJECT = Nothing
cnnDB.Close
Set cnnDB = Nothing
End Sub
ACCESS引用ADOX,可以定义数据库的内部结构,如表,查询等,
VBA动态修改传递查询的SQL语句,
工具-引用,Microsoft ADO Ext. 2.8 for DLL and Security
Public Sub ChangeSQL(strPassThroughQueryName As String, strPassthroughSQL As String)
Dim cat As New ADOX.Catalog
Dim Pro As ADOX.Procedure
Dim Cmm As New ADODB.Command
If strPassthroughSQL = "" or Len(strPassthroughSQL) = 0 Then Exit Sub
Set cat.ActiveConnection = CurrentProject.Connection
Set Pro = cat.Procedures(strPassThroughQueryName)
Set Cmm = Pro.Command
Cmm.CommandText = strPassthroughSQL
Set Pro.Command = Cmm
Set cat = Nothing
Set Pro = Nothing
Set Cmm = Nothing
End Sub
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- Access对子窗体数据进行批...(10.30)
- 最精简的组合框行来源数据快速输...(10.25)
- Access仿平台的多值选择器...(10.24)
- 【Access日期区间段查询】...(10.22)
- 【Access源码示例】VBA...(10.12)
- Access累乘示例,Acce...(10.09)
- 数值8.88,把整数8去掉,转...(10.08)
- 【Access自定义函数】一个...(09.30)
- 【Access选项卡示例】Ac...(09.09)
学习心得
最新文章
- Access判断多条明细的配方或订...(11.30)
- 如何让后台数据库在局域网共享时,且...(11.29)
- 【Access月初月末日期设置方法...(11.29)
- 【Access IIF函数嵌套示例...(11.26)
- Access快速开发平台--使用组...(11.25)
- Access快速开发平台--对上传...(11.22)
- Access快速开发平台企业版--...(11.18)
- 不会用多表联合查询,多表查询没结果...(11.16)
- 【案例分享】主键字段值含有不间断空...(11.16)
- Access快速开发平台--后台D...(11.14)