首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

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

2012-04-25 
为什么输入重复的用户名也不提示重复啊Do While rs.EOFrs.Open select username from information , cn,

为什么输入重复的用户名也不提示重复啊
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 

热点排行