为什么输入重复的用户名也不提示重复啊
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
[解决办法]
'判断输入的用户是否存在
strsql=" SELECT username FROM information WHERE username='"& trim(txtusername.text) &"'"
if rs.state<>adstateclosed then rs.close
rs.open strsql,cn,adopenkeyset,adlockreadonly
if rs.recordcount>0 then
label21.forecolor=vbred
label21.capiton="用户名已经在在"
label21.refresh
msgbox "用户名已经在在!",48,"错误"
goto aa
else
goto bb
end if