vb 3705 对象打开时不允许操作

来源:百度知道 编辑:UC知道 时间:2024/05/30 13:35:28
Dim SQL As String
Dim S As String
Dim flag1 As Integer
Dim flag2 As Integer

Private Sub Command1_Click()
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\小程序\db1.mdb;Persist Security Info=False"

S = Text1.Text
If Text1.Text = "" Then
MsgBox "请输入用户名!", vbInformation, "消息提醒"
Else
SQL = "Select * From 用户信息表 where 名称='" & S & "'"
Rs.Open SQL, Conn, 1, 3
If Rs.EOF Then
MsgBox "此用户数据库中不存在,请重新输入!", vbExclamation, "消息提醒"
Else
If Rs.Fields(2) > 100 Then
MsgBox "老大先还债吧!", vbInformation, "消息提醒"
Else
If (Rs.Fields(2) < 100& & Rs.Fields(2) > 30) Then
flag1 = 1
If (Rs.Fields(2) < 30) Then
flag1 = 0
Rs.Close
End If
End If
End If
End If
End If
<

没有及时的关闭rs对象,给你改了一下,你再试试
Dim SQL As String
Dim S As String
Dim flag1 As Integer
Dim flag2 As Integer

Private Sub Command1_Click()
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\小程序\db1.mdb;Persist Security Info=False"

S = Text1.Text
If Text1.Text = "" Then
MsgBox "请输入用户名!", vbInformation, "消息提醒"
Else
SQL = "Select * From 用户信息表 where 名称='" & S & "'"
Rs.Open SQL, Conn, 1, 3
If Rs.EOF Then
MsgBox "此用户数据库中不存在,请重新输入!", vbExclamation, "消息提醒"
Else
If Rs.Fields(2) > 100 Then
MsgBox "老大先还债吧!", vbInformation, "消息提醒"
Else
If (Rs.Fields(2) < 100& & Rs.Fields