如何实现注册时检测所注册的用户名已经存在?
下面是我的代码,看一下哪儿有问题:dim str as string
Dim hname As String = Request.QueryString(usname.Text)
Dim strs As String = "select * from users where username='" & hname & "'"
Dim cmd2 As New OleDbCommand(strs, conn)
conn.Open()
Dim dr As OleDbDataReader = cmd2.ExecuteReader()
If dr.Read() = True Then
message.Text = "此用户已经存在!"
Else
str = "insert into users(username,userpwd,realname,) values('" & usname.Text & "','" & uspwd.Text & "','" & realname.Text & "')"
Dim cmd As New OleDbCommand(str, conn)
cmd.ExecuteNonQuery() '提示这行有错
conn.Close()
message.Text = "注册成功!"
End If
提示错误:已有打开的与此连接相关联的 DataReader,必须首先将它关闭。
我整个页面就只有这一个conn.open()啊,怎么会出这个错误呢???