In my asp.net +vb+access web i have made a login page and the code is as under
Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\web\auth.mdb"
Dim con As OleDbConnection = New OleDbConnection(connectString)
con.Open()
Dim cmd As New OleDbCommand("select * from Users where userid =@userid and Password=@password", con)
cmd.Parameters.AddWithValue("@userid", txtUserName.Text)
cmd.Parameters.AddWithValue("@password", txtPWD.Text)
Dim rdr As OleDbDataReader
Try
con.Open()
rdr = cmd.ExecuteReader()
If rdr.HasRows() = True Then
While (rdr.Read())
Session("userid") = rdr("userid")
Session("sect") = rdr("sect")
Dim url As String = Request.QueryString("url")
If Not String.IsNullOrEmpty(url) Then
Response.Redirect(Server.UrlDecode(url))
End If
End While
End If
Catch ex As Exception
Response.Write(Err.Description)
Finally
con.Close()
End Try
I am getting error The connection was not closed. The connection's current state is open.