ADODB.Connection Public dbConn As ADODB.ConnectionPublic stuRs As ADODB.RecordsetPublic SqlFindStr As StringPublic Function Conn2DB() As Boolean'公共Access数据库连函数Dim connStr As StringDim dbName As StringdbName = App.Path & "\" & "Student

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 00:06:26
ADODB.Connection Public dbConn As ADODB.ConnectionPublic stuRs As ADODB.RecordsetPublic SqlFindStr As StringPublic Function Conn2DB() As Boolean'公共Access数据库连函数Dim connStr As StringDim dbName As StringdbName = App.Path &
xT]OA+cc,$M17[B"vw*ewTALU1R@ٙ.ٝ,Zsϙs瞙!3Ǣ,CI 3$1a@DW.AGA:D.̍%Yfs O];#TXݦD%yُ'wd9"PIDfќU]:Ii et" ~ [g9B hKfFx9⿵!44\uZDKJ `iZvvWaה#I]I.u7x^G<&mQ := $]RC<1B C-a8A9'%'fLCZhx@]/n-:O}$ug{;`'mk}ڬdejVS/~ ϖ_=]({H76̎/C8Jtҫ*Ғ$.ϪRc_ήqsmmgHv,c<"X Xx7SxLgI~FC eʞuzzբߪ˫7h \رtOi^Msz՘ <;Hn0>jk쇹PdTfsu$7IjfU^[OK`

ADODB.Connection Public dbConn As ADODB.ConnectionPublic stuRs As ADODB.RecordsetPublic SqlFindStr As StringPublic Function Conn2DB() As Boolean'公共Access数据库连函数Dim connStr As StringDim dbName As StringdbName = App.Path & "\" & "Student
ADODB.Connection
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
中间的几局长的代码最不懂是什么意思,还请大虾们指教!

ADODB.Connection Public dbConn As ADODB.ConnectionPublic stuRs As ADODB.RecordsetPublic SqlFindStr As StringPublic Function Conn2DB() As Boolean'公共Access数据库连函数Dim connStr As StringDim dbName As StringdbName = App.Path & "\" & "Student
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连接字符串
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