读书人

为什么输入重复的用户名也不提示重复啊

发布时间: 2012-04-25 19:32:32 作者: rapoo

为什么输入重复的用户名也不提示重复啊
Do While rs.EOF
rs.Open "select username from information ", cn, adOpenStatic, adLockOptimistic
If txtusername.Text = rs.Fields("username") Then
Label21.ForeColor = vbRed
Label21.Caption = "用户名已存在"
MsgBox "用户名已存在!", vbInformation, "用户错误"
GoTo aa
Else
GoTo bb
End If
Loop

[解决办法]

VB code
'判断输入的用户是否存在strsql=" SELECT username FROM information WHERE username='"& trim(txtusername.text) &"'"if rs.state<>adstateclosed then rs.closers.open strsql,cn,adopenkeyset,adlockreadonlyif rs.recordcount>0 then    label21.forecolor=vbred    label21.capiton="用户名已经在在"    label21.refresh    msgbox "用户名已经在在!",48,"错误"    goto aaelse    goto bbend if 

读书人网 >VB

热点推荐