VB代码求助
PublicFunctionUpdateRepair()AsBooleanDimWsAsWorkspaceDimDbAsDatabaseDimRsAsRecordsetD...
Public Function UpdateRepair() As Boolean
Dim Ws As Workspace
Dim Db As Database
Dim Rs As Recordset
Dim SQLs As String
On Error Resume Next
Set Ws = DBEngine.Workspaces(0)
Set Db = Ws.OpenDatabase(App.Path & "\housing.mdb")
SQLs = "Select * From Park where 住户名称='" & ListView1.SelectedItem.SubItems(1) & "'"
Set Rs = Db.OpenRecordset(SQLs, dbOpenDynaset)
If Not Rs.EOF Then
Rs.Edit
Rs.Fields("车位编号") = Text1.Text
'Rs.Fields("住户名称") = Text2.Text
Rs.Fields("使用日期") = DTPicker1.Value
Rs.Fields("备注") = Text3.Text
Rs.Update
MsgBox "修改成功!", 64,
UpdateRepair = True
Else
MsgBox "无此住户的车位资料!", 64,
UpdateRepair = False
End If
Rs.Close
Db.Close
Ws.Close
Set Rs = Nothing
Set Db = Nothing
Set Ws = Nothing
End Function
谁可以帮我解释下这段代码的意思Set Rs = Nothing又是什么意思啊 展开
Dim Ws As Workspace
Dim Db As Database
Dim Rs As Recordset
Dim SQLs As String
On Error Resume Next
Set Ws = DBEngine.Workspaces(0)
Set Db = Ws.OpenDatabase(App.Path & "\housing.mdb")
SQLs = "Select * From Park where 住户名称='" & ListView1.SelectedItem.SubItems(1) & "'"
Set Rs = Db.OpenRecordset(SQLs, dbOpenDynaset)
If Not Rs.EOF Then
Rs.Edit
Rs.Fields("车位编号") = Text1.Text
'Rs.Fields("住户名称") = Text2.Text
Rs.Fields("使用日期") = DTPicker1.Value
Rs.Fields("备注") = Text3.Text
Rs.Update
MsgBox "修改成功!", 64,
UpdateRepair = True
Else
MsgBox "无此住户的车位资料!", 64,
UpdateRepair = False
End If
Rs.Close
Db.Close
Ws.Close
Set Rs = Nothing
Set Db = Nothing
Set Ws = Nothing
End Function
谁可以帮我解释下这段代码的意思Set Rs = Nothing又是什么意思啊 展开
2个回答
展开全部
由于前面的定义
Dim Rs As Recordset
所以在使用完Rs后需要关闭连接,释放资源。
Set Rs = Nothing就是释放Recordset对象的资源。
Dim Rs As Recordset
所以在使用完Rs后需要关闭连接,释放资源。
Set Rs = Nothing就是释放Recordset对象的资源。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询