VB中连接Access时提示连接无法用于执行此操作,在此上下文中可能已被关闭或无效。 20
DimcnnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetPrivateSubCommand1_Click()Dimrs1A...
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
Dim rs1 As New ADODB.Recordset
If Text1(0) = "" Then
MsgBox "用户名不得为空!"
Text1(0).SetFocus
Exit Sub
End If
rs1.CursorLocation = adUseClient
rs1.Open "select * from 摄影师用户信息 where 用户名=trim('" & Text1(0) & "')", cnn, adOpenDynamic, adLockOptimistic
If rs1.RecordCount <> 0 Then
MsgBox "该用户名已被注册,请更换新的用户名!"
Text1(0).SetFocus
rs1.Close
Exit Sub
End If
If Text1(1) = "" Then
MsgBox "密码不得为空!"
Text1(1).SetFocus
Exit Sub
End If
If Len(Text1(1)) <> 6 Then
MsgBox "请注意,密码长度必须是6位!"
Exit Sub
End If
If Text1(2) = "" Then
MsgBox "确认密码不得为空!"
Exit Sub
End If
If Text1(2) <> Text1(1) Then
MsgBox "对不起,确认密码与密码不一致,请重新输入!"
Text1(2).SetFocus
Exit Sub
End If
rs.CursorLocation = adUseClient
rs.Open "select * from 摄影师用户信息", cnn, adOpenDynamic, adLockOptimistic
rs.AddNew
rs.Fields("用户名") = Text1(0).Text
rs.Fields("密码") = Text1(2).Text
rs.Fields("微信号") = Text1(5).Text
rs.Fields("联系电话") = Text1(6).Text
rs.Fields("摄影风格") = Text1(7).Text
If Option1.Value = True Then
rs.Fields("性别") = "男"
ElseIf Option2.Value = True Then
rs.Fields("性别") = "女"
End If
rs.Update
MsgBox "注册成功!您的账号名为" & Text1(0)
rs.Close
cnn.Close
End Sub
Private Sub Command2_Click()
注册.Hide
Form1.Show
End Sub
我删去rs1.close也没用,vb是刚学,啥也不懂,代码是别人的 展开
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
Dim rs1 As New ADODB.Recordset
If Text1(0) = "" Then
MsgBox "用户名不得为空!"
Text1(0).SetFocus
Exit Sub
End If
rs1.CursorLocation = adUseClient
rs1.Open "select * from 摄影师用户信息 where 用户名=trim('" & Text1(0) & "')", cnn, adOpenDynamic, adLockOptimistic
If rs1.RecordCount <> 0 Then
MsgBox "该用户名已被注册,请更换新的用户名!"
Text1(0).SetFocus
rs1.Close
Exit Sub
End If
If Text1(1) = "" Then
MsgBox "密码不得为空!"
Text1(1).SetFocus
Exit Sub
End If
If Len(Text1(1)) <> 6 Then
MsgBox "请注意,密码长度必须是6位!"
Exit Sub
End If
If Text1(2) = "" Then
MsgBox "确认密码不得为空!"
Exit Sub
End If
If Text1(2) <> Text1(1) Then
MsgBox "对不起,确认密码与密码不一致,请重新输入!"
Text1(2).SetFocus
Exit Sub
End If
rs.CursorLocation = adUseClient
rs.Open "select * from 摄影师用户信息", cnn, adOpenDynamic, adLockOptimistic
rs.AddNew
rs.Fields("用户名") = Text1(0).Text
rs.Fields("密码") = Text1(2).Text
rs.Fields("微信号") = Text1(5).Text
rs.Fields("联系电话") = Text1(6).Text
rs.Fields("摄影风格") = Text1(7).Text
If Option1.Value = True Then
rs.Fields("性别") = "男"
ElseIf Option2.Value = True Then
rs.Fields("性别") = "女"
End If
rs.Update
MsgBox "注册成功!您的账号名为" & Text1(0)
rs.Close
cnn.Close
End Sub
Private Sub Command2_Click()
注册.Hide
Form1.Show
End Sub
我删去rs1.close也没用,vb是刚学,啥也不懂,代码是别人的 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询