VB中 显示要求对象 应该怎么改
PrivateSubCommand1_Click()IfText1.Text=""OrText2.Text=""OrText3.Text=""OrText4.Text="...
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then
MsgBox "输入不能为空!!", 48, "提示信息"
Else
'判断输入的用户名在数据库中是否存在
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
sqlconnection = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\jxc.mdb"
Rs.Open "select * from [user1] where name = '" & Trim(Text1.Text) & "' and password= '" & Trim(Text2.Text) & "'", sqlconnection
If Rs.RecordCount > 0 Then
If Text3.Text <> Text4.Text Then '判断数据的密码是否正确
MsgBox "两次输入的密码不一致,请您确认后重新输入", 48, "提示信息"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
Else
'如果输入正确的密码则修改密码
Set adoRs = adoCon.Execute("UPDATE user1 SET Password= '" + Text4.Text + "' where name='" + Text1.Text + "'") 显示要求对象 ,(不是太懂这句话,是用的别我的代码改的,)
Adodc1.Refresh
MsgBox "密码修改成功,请您记住新密码", , "信息提示"
Unload Me
End If
Else
MsgBox "没有此用户的信息,请您确认后重新输入", 48, "信息提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End If
End If
adoCon.Close
End Sub 展开
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then
MsgBox "输入不能为空!!", 48, "提示信息"
Else
'判断输入的用户名在数据库中是否存在
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
sqlconnection = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\jxc.mdb"
Rs.Open "select * from [user1] where name = '" & Trim(Text1.Text) & "' and password= '" & Trim(Text2.Text) & "'", sqlconnection
If Rs.RecordCount > 0 Then
If Text3.Text <> Text4.Text Then '判断数据的密码是否正确
MsgBox "两次输入的密码不一致,请您确认后重新输入", 48, "提示信息"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
Else
'如果输入正确的密码则修改密码
Set adoRs = adoCon.Execute("UPDATE user1 SET Password= '" + Text4.Text + "' where name='" + Text1.Text + "'") 显示要求对象 ,(不是太懂这句话,是用的别我的代码改的,)
Adodc1.Refresh
MsgBox "密码修改成功,请您记住新密码", , "信息提示"
Unload Me
End If
Else
MsgBox "没有此用户的信息,请您确认后重新输入", 48, "信息提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End If
End If
adoCon.Close
End Sub 展开
1个回答
展开全部
sqlconnection这个对象没有被赋值,这个变量应该是一个adodb.connection的对象,但是从代码看,上一行是连接字符串,应该代码是看错了。
追问
那应该怎么改呢,他原来就是写的
Set adoRs = adoCon.Execute("UPDATE user1 SET Password= '" + Text4.Text + "' where name='" + Text1.Text + "'")
追答
dim adocon as new adodb.connection
adodcon.open sqlconnection
Rs.Open "select * from [user1] where name = '" & Trim(Text1.Text) & "' and password= '" & Trim(Text2.Text) & "'", adodcon
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询