| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1631 人关注过本帖, 1 人收藏
标题:用户登录界面还是不够完美如何改进啊?
只看楼主 加入收藏
红影
Rank: 1
等 级:新手上路
威 望:2
帖 子:659
专家分:0
注 册:2006-2-22
结帖率:66.67%
收藏(1)
 问题点数:0 回复次数:8 
用户登录界面还是不够完美如何改进啊?

我在SQL中建了一个数据库名叫test,里面放了一张表名叫load,表里存放用户ID,Name,和Password,然后做了一个登录的界面,输入用户名密码,点“登录”按钮,如果正确显示“登录成功”,错误显示“你输入的用户名或密码有误!”

这怎么做?

[此贴子已经被作者于2007-7-27 22:57:55编辑过]

搜索更多相关主题的帖子: SQL 界面 数据库 用户 改进 
2007-07-26 20:31
红影
Rank: 1
等 级:新手上路
威 望:2
帖 子:659
专家分:0
注 册:2006-2-22
收藏
得分:0 
回复:(红影)用SQL数据库做用户登录界面

Option Explicit
Public conn As ADODB.Connection
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "rovider=MSDASQL.1ersist Security Info=False;" _
+ "User ID=sa;password=sa;Initial Catalog=myDb.mdb;Data Source= 10.173.0.231"
conn.Open
from1.Show '登录界面
End Sub

Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
Text2.SetFocus
Exit Sub
End If

Dim strSQl As String
strSQl = "select * from load where Name='" & Trim$(Text1.Text) & "' and password='" & Trim$(Text2.Text) & "' "

Dim str As New ADODB.Recordset
Dim Try_times As Integer
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQl, conn, adOpenStatic, adLockReadOnly

With str
If .State = adStateOpen Then .Close
.Open strSQl
If .EOF Then
Try_times = Try_times + 1
If Try_times >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"
Unload Me
Else
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
End If
Else

Unload Me

Form2.Show '登录进入的另一个界面

End If
End With

End Sub

Private Sub Command2_Click()
End
End Sub

红色这句提示错误:

图片附件: 游客没有浏览图片的权限,请 登录注册


这怎么改啊???

生命中,不断有人离开和进入。于是,看见的,看不见了;记住的,遗忘了。
2007-07-26 23:00
心中有剑
Rank: 2
等 级:新手上路
威 望:5
帖 子:611
专家分:0
注 册:2007-5-18
收藏
得分:0 
Dim str As New ADODB.Recordset

Set str = New ADODB.Recordset
这两句重复了

2007-07-27 11:57
红影
Rank: 1
等 级:新手上路
威 望:2
帖 子:659
专家分:0
注 册:2006-2-22
收藏
得分:0 

改好了现在可以正常运行了,但是还是有个地方觉得不完美,希望高手来帮忙给改改!

我的这个现在限制了密码输入错误的次数为三次,用户名输入错误的次数也为三次
但是如果我先输错了2次密码,后又输入了2次错误的用户名,第5次如果输入的是错误的密码就提示“您已经连续三次输入错误密码,请查证后再进行登录!”,程序退出;如果输入的是错误的用户名就提示“您已经连续三次输入不存在的用户名,请查证后再进行登录!”,程序退出。这样感觉很不完善,如果能在第五次的时候不论是输入错误的密码还是错误的用户名都能给出一个新的提示“您已经连续五次输入了错误的用户名或密码!!!请进行查证!”,程序退出,这样多好,我弄了一下午也弄不出这个效果,谁能修改下我下面的代码把这个效果实现???


Option Explicit
Private gdbConn As New ADODB.Connection
Dim llCount As Long
Dim luCount As Long
Dim lsCount As Long


Private Sub Command1_Click()


If Text1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
Text1.SetFocus
Exit Sub
End If

If Text2.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
Text2.SetFocus
Exit Sub
End If

Dim lrRec As New ADODB.Recordset
Dim lsSql As String

lsSql = "select * from login where Name='" & Trim$(Text1.Text) & "'"

gdbConn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=CX;Initial Catalog=test"

gdbConn.Open

lrRec.Open lsSql, gdbConn, adOpenKeyset, adLockOptimistic

If lrRec.RecordCount <> 0 Then

If lrRec.Fields("Password") = Text2.Text Then
Form2.Show
Unload Me

Else
If llCount >= 2 Then
MsgBox "您已经连续三次输入错误密码,请查证后再进行登录!", vbExclamation + vbOKOnly, "登陆失败"
lrRec.Close
Unload Me
Exit Sub
Else
llCount = llCount + 1
MsgBox "密码错误!请重新输入!", vbExclamation + vbOKOnly, "友情提示"
Text2.Text = ""
Text2.SetFocus
gdbConn.Close
Exit Sub
End If
End If

Else
If luCount >= 2 Then
MsgBox "您已经连续三次输入不存在的用户名,请查证后再进行登录!", vbExclamation + vbOKOnly, "登陆失败"
lrRec.Close
Unload Me
Exit Sub
Else
luCount = luCount + 1
MsgBox "该用户不存在!请重新输入!", vbExclamation + vbOKOnly, "友情提示"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
gdbConn.Close
Exit Sub
End If
Exit Sub

End If
Exit Sub
End Sub

Private Sub Command2_Click()
Set gdbConn = Nothing
Unload Me
End Sub


生命中,不断有人离开和进入。于是,看见的,看不见了;记住的,遗忘了。
2007-07-27 22:55
slore
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1108
专家分:0
注 册:2005-7-1
收藏
得分:0 

Option Explicit

Private gdbConn As New ADODB.Connection
Dim llCount As Long
Dim
luCount As Long
Dim
lsCount As Long

Private Sub Command1_Click()

If Text1 = "" Then
MsgBox
"用户名不能为空!",vbInformation, "友情提示"
Text1.SetFocus
Exit Sub
End If

If Text2 = "" Then
MsgBox
"密码不能为空!",vbInformation, "友情提示"
Text2.SetFocus
Exit Sub
End If

Dim lrRec As New ADODB.Recordset
Dim lsSql As String

lsSql = "select * from login where Name='" & Trim$(Text1) & "'"

gdbConn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=CX;Initial Catalog=test"
gdbConn.Open

lrRec.Open lsSql, gdbConn, adOpenKeyset, adLockOptimistic
If lrRec.RecordCount <> 0 Then
If
lrRec.Fields("Password") = Text2 Then
Form2.Show
Unload Me
Else
If
llCount = 3 Then
If
luCount > 0 Then
lsSql = Mid("四五",luCount,1)
MsgBox "您已经连续" & lsSql & "次输入了错误的用户名或密码!!!请进行查证!",vbCritical,"登陆失败"
Else
MsgBox
"您已经连续三次输入错误密码,请查证后再进行登录!", vbExclamation, "登陆失败"
End If
lrRec.Close
Unload
Me
Else
llCount = llCount + 1
MsgBox "密码错误!请重新输入!", vbExclamation, "友情提示"
Text2 = ""
Text2.SetFocus
gdbConn.Close
End If
End If
Else
If
luCount = 3 Then
If
llCount > 0 Then
lsSql = Mid("四五",llCount,1)
MsgBox "您已经连续" & lsSql & "次输入了错误的用户名或密码!!!请进行查证!",vbCritical,"登陆失败"
Else
MsgBox
"您已经连续三次输入不存在的用户名,请查证后再进行登录!", vbExclamation, "登陆失败"
End If
lrRec.Close
Unload
Me
Else
luCount = luCount + 1
MsgBox "该用户不存在!请重新输入!", vbExclamation, "友情提示"
Text1 = ""
Text2 = ""
Text1.SetFocus
gdbConn.Close
End If
End If
End Sub

'Exit Sub没有意义。。。Msgbox默认就是vbOKOnly不需要,恩,没有数据库环境你看着用,不行自己改下就是那个思路

[此贴子已经被作者于2007-7-28 0:22:48编辑过]


快上课了……
2007-07-28 00:10
taihongbo
Rank: 1
来 自:山东临沂
等 级:新手上路
帖 子:127
专家分:0
注 册:2004-11-15
收藏
得分:0 

在这个例子里有完整的登陆界面。

压缩文件超过521K,不能上传,到我的站上下载。
http://www.lshsoft.net/lshbbs/dispbbs.asp?boardID=23&ID=305&page=1

看见大家那么辛苦的寻找,把我的一个小东西发给大家参考参考。
感觉有用处就顶一下。


淘宝 毛绒玩具 熊
jstbobo.taobao. com
久顺通啵啵玩具店
2007-07-28 09:34
红影
Rank: 1
等 级:新手上路
威 望:2
帖 子:659
专家分:0
注 册:2006-2-22
收藏
得分:0 
以下是引用slore在2007-7-28 0:10:17的发言:

Option Explicit

Private gdbConn As New ADODB.Connection
Dim llCount As Long
Dim
luCount As Long
Dim
lsCount As Long

Private Sub Command1_Click()

If Text1 = "" Then
MsgBox
"用户名不能为空!",vbInformation, "友情提示"
Text1.SetFocus
Exit Sub
End If

If Text2 = "" Then
MsgBox
"密码不能为空!",vbInformation, "友情提示"
Text2.SetFocus
Exit Sub
End If

Dim lrRec As New ADODB.Recordset
Dim lsSql As String

lsSql = "select * from login where Name='" & Trim$(Text1) & "'"

gdbConn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=CX;Initial Catalog=test"
gdbConn.Open

lrRec.Open lsSql, gdbConn, adOpenKeyset, adLockOptimistic
If lrRec.RecordCount <> 0 Then
If
lrRec.Fields("Password") = Text2 Then
Form2.Show
Unload Me
Else
If
llCount = 3 Then
If
luCount > 0 Then
lsSql = Mid("四五",luCount,1)
MsgBox "您已经连续" & lsSql & "次输入了错误的用户名或密码!!!请进行查证!",vbCritical,"登陆失败"
Else
MsgBox
"您已经连续三次输入错误密码,请查证后再进行登录!", vbExclamation, "登陆失败"
End If
lrRec.Close
Unload
Me
Else
llCount = llCount + 1
MsgBox "密码错误!请重新输入!", vbExclamation, "友情提示"
Text2 = ""
Text2.SetFocus
gdbConn.Close
End If
End If
Else
If
luCount = 3 Then
If
llCount > 0 Then
lsSql = Mid("四五",llCount,1)
MsgBox "您已经连续" & lsSql & "次输入了错误的用户名或密码!!!请进行查证!",vbCritical,"登陆失败"
Else
MsgBox
"您已经连续三次输入不存在的用户名,请查证后再进行登录!", vbExclamation, "登陆失败"
End If
lrRec.Close
Unload
Me
Else
luCount = luCount + 1
MsgBox "该用户不存在!请重新输入!", vbExclamation, "友情提示"
Text1 = ""
Text2 = ""
Text1.SetFocus
gdbConn.Close
End If
End If
End Sub

'Exit Sub没有意义。。。Msgbox默认就是vbOKOnly不需要,恩,没有数据库环境你看着用,不行自己改下就是那个思路


按照你说的做了一些修改,现在已经达到效果了。。。

非常感谢啊!!!

Option Explicit
Private gdbConn As New ADODB.Connection
Dim llCount As Long
Dim luCount As Long


Private Sub Command1_Click()


If Text1.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
Text1.SetFocus
Exit Sub
End If

If Text2.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
Text2.SetFocus
Exit Sub
End If

Dim lrRec As New ADODB.Recordset
Dim lsSql As String

lsSql = "select * from login where Name='" & Trim$(Text1.Text) & "'"

gdbConn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=CX;Initial Catalog=test"

gdbConn.Open

lrRec.Open lsSql, gdbConn, adOpenKeyset, adLockOptimistic

If lrRec.RecordCount <> 0 Then

If lrRec.Fields("Password") = Text2.Text Then
Form2.Show
Unload Me

Else
If llCount = 2 Then
If luCount > 0 Then
lsSql = Mid("四五", luCount, 1)
MsgBox "您已经连续" & lsSql & "次输入了错误的用户名或密码!!!请进行查证!", vbCritical, "登陆失败"
Else
MsgBox "您已经连续三次输入错误密码,请查证后再进行登录!", vbExclamation + vbOKOnly, "登陆失败"
End If
lrRec.Close
Unload Me

Else
llCount = llCount + 1
MsgBox "密码错误!请重新输入!", vbExclamation + vbOKOnly, "友情提示"
Text2.Text = ""
Text2.SetFocus
gdbConn.Close
End If
End If

Else
If luCount = 2 Then
If llCount > 0 Then
lsSql = Mid("四五", llCount, 1)
MsgBox "您已经连续" & lsSql & "次输入了错误的用户名或密码!!!请进行查证!", vbCritical, "登陆失败"
Else
MsgBox "您已经连续三次输入不存在的用户名,请查证后再进行登录!", vbExclamation + vbOKOnly, "登陆失败"
End If
lrRec.Close
Unload Me
Else
luCount = luCount + 1
MsgBox "该用户不存在!请重新输入!", vbExclamation + vbOKOnly, "友情提示"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
gdbConn.Close
End If
End If

End Sub

Private Sub Command2_Click()
Set gdbConn = Nothing
Unload Me
End Sub


生命中,不断有人离开和进入。于是,看见的,看不见了;记住的,遗忘了。
2007-07-28 11:01
slore
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1108
专家分:0
注 册:2005-7-1
收藏
得分:0 
呵呵,失误啊,写成3了=.=

没有环境调试郁闷……

快上课了……
2007-07-28 11:55
快速回复:用户登录界面还是不够完美如何改进啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019368 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved