主题:[讨论]我做了一个用户登陆页面出现如下错误
后台数据库是access语言vb.net
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
Response.Write("<script language=vbscript>alert""请填写完整,再提交.""</script>")
Else
Try
OleDbConnection1.Open()
Catch ex As Exception
Response.Write("<script language=vbscript>alert""数据库错误,请查询.""</script>+ex")
End Try
OleDbCommand1.CommandText = "select*from tabname where sname='" & TextBox1.Text & "' and pwd='" & TextBox2.Text & "'"
Dim reader As OleDbDataReader
reader = OleDbCommand1.ExecuteReader
If reader.Read = False Then
Response.Write("<script language=vbscript>alert"" 用户名不存在,请查询在登入.""</script>")
OleDbConnection1.Close()
reader.Close()
Else
reader.Close()
Response.Redirect("http://localhost/jiaohu/gnanli.aspx")
OleDbConnection1.Close()
End If
End If
End Sub
单击提交后出现如下
ExecuteReader 需要打开的并且可用的连接。该连接的当前状态是 Closed。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: ExecuteReader 需要打开的并且可用的连接。该连接的当前状态是 Closed。
源错误:
行 65: OleDbCommand1.CommandText = "select*from tabname where sname='" & TextBox1.Text & "' and pwd='" & TextBox2.Text & "'"
行 66: Dim reader As OleDbDataReader
行 67: reader = OleDbCommand1.ExecuteReader
行 68:
行 69:
源文件: c:\inetpub\wwwroot\jiaohupintai\guanliyuan.aspx.vb 行: 67
堆栈跟踪:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
Response.Write("<script language=vbscript>alert""请填写完整,再提交.""</script>")
Else
Try
OleDbConnection1.Open()
Catch ex As Exception
Response.Write("<script language=vbscript>alert""数据库错误,请查询.""</script>+ex")
End Try
OleDbCommand1.CommandText = "select*from tabname where sname='" & TextBox1.Text & "' and pwd='" & TextBox2.Text & "'"
Dim reader As OleDbDataReader
reader = OleDbCommand1.ExecuteReader
If reader.Read = False Then
Response.Write("<script language=vbscript>alert"" 用户名不存在,请查询在登入.""</script>")
OleDbConnection1.Close()
reader.Close()
Else
reader.Close()
Response.Redirect("http://localhost/jiaohu/gnanli.aspx")
OleDbConnection1.Close()
End If
End If
End Sub
单击提交后出现如下
ExecuteReader 需要打开的并且可用的连接。该连接的当前状态是 Closed。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: ExecuteReader 需要打开的并且可用的连接。该连接的当前状态是 Closed。
源错误:
行 65: OleDbCommand1.CommandText = "select*from tabname where sname='" & TextBox1.Text & "' and pwd='" & TextBox2.Text & "'"
行 66: Dim reader As OleDbDataReader
行 67: reader = OleDbCommand1.ExecuteReader
行 68:
行 69:
源文件: c:\inetpub\wwwroot\jiaohupintai\guanliyuan.aspx.vb 行: 67
堆栈跟踪: