标题:已有打开的与此命令相关联的datareader,必须首先将它关闭
只看楼主
小南瓜
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2005-5-25
 问题点数:0 回复次数:2 
已有打开的与此命令相关联的datareader,必须首先将它关闭

Dim conn As OleDbConnection
Dim user As String
Dim psw As String
Dim dr1 As OleDbDataReader
user = textbox1.Text
psw = textbox2.Text

conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("test.mdb"))
Dim check1 As String
check1 = "select count(*) from student where studentname='" + user + "'"

Dim cmd1 As New OleDbCommand(check1, conn)

Try
conn.Open()
dr1 = cmd1.ExecuteReader()
dr1.Read()
Dim count As String


count = cmd1.ExecuteScalar()

dr1.Close()
conn.Close()
If count <> 0 Then
Dim check2 As String
Dim dr2 As OleDbDataReader
check2 = "select *from student "
Dim cmd2 As New OleDbCommand(check2, conn)
Try
conn.Open()

dr2 = cmd2.ExecuteReader()
dr2.Read()


conn.Close()

If psw = dr2("studentpassword") Then
Response.Redirect("学生界面.aspx")
Else
Label3.Text = "登录密码错误"

End If

Catch ex As Exception
Response.Write(ex.Message)
End Try

Else
Label3.Text = "没有注册的用户"

End If






各位都帮我看一下吧,不知道这个错误提示是什么意思,怎么改?

搜索更多相关主题的帖子: datareader Dim quot 命令 String 
2006-05-27 12:55
xufengtang
Rank: 1
等 级:新手上路
威 望:1
帖 子:89
专家分:0
注 册:2006-5-7
得分:0 
在用datareader2的时候要先把datareader1关闭
即在用dr2.read()之前要先dr1.close()

2006-05-27 15:11
小南瓜
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2005-5-25
得分:0 
但是语句中不是有.dr1.close 吗?
2006-05-27 16:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-67688-1-1.html




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

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