ADODB.Connection是什么意思(2008-12-28 16:03:11)
转载▼
标签:
分类:程序
杂谈
Public dbConn As ADODB.Connection
Public stuRs As ADODB.Recordset
Public SqlFindStr As String
Public Function Conn2DB() As Boolean
'公共Access数据库连函数
Dim connStr As String
Dim dbName As String
dbName = App.Path & "\" & "StudentDB.mdb"
' Access连接字符串
conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbName
Set dbConn = New ADODB.Connection
If dbConn.State <> adStateOpen Then
dbConn.Open conStr
End If
Conn2DB = True
End Function
Public Function ExcSQL(ByVal sql As String) As ADODB.Recordset
Dim rst As ADODB.Recordset
'执⾏⼀条SQL查询,得到⼀个记录集
Set rst = New ADODB.Recordset
rst.Open Trim$(sql), dbConn, adOpenKeyset, adLockOptimistic
Set ExcSQL = rst
End Function
想知道这段代码是什么意思,急啊!!!谢谢⼤虾帮忙啊!!SOS
Public dbConn As ADODB.Connection '定义⼀个ADODB连接
Public stuRs As ADODB.Recordset '定义Recordset对象
Public SqlFindStr As String
Public Function Conn2DB() As Boolean
'公共Access数据库连函数
Dim connStr As String
Dim dbName As String
dbName = App.Path & "\" & "StudentDB.mdb" '返回程序所在路径
' Access连接字符串
access是什么意思啊了conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbName Set dbConn = New ADODB.Connection '定义⼀个ADODB连接对象
If dbConn.State <> adStateOpen Then '判断ADODB连接是否打开dbConn.Open conStr '如果不是打开状态就打开连接
End If
Conn2DB = True
End Function
Public Function ExcSQL(ByVal sql As String) As ADODB.Recordset Dim rst As ADODB.Recordset
'执⾏⼀条SQL查询,得到⼀个记录集
Set rst = New ADODB.Recordset
rst.Open Trim$(sql), dbConn, adOpenKeyset, adLockOptimistic '得到记录Set ExcSQL = rst
End Function
ADODB是数据库访问组件,connection是其中的⼀个对象

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。