Hi,
I have a login page connected to SQL database that gives me error.
ExecuteReader requires an open and available Connection. The connection's current state is Closed.
Code:
Dim strconn As String
Dim strsql As String
Dim command As SqlCommand
Dim i As Integer
Try
strconn = "server =(local);trusted_connection=yes;database=consultants;"
Response.Write("connection ok")
Dim conn As New SqlConnection(strconn)
strsql = "select count(*) from consul_login where uname='" & txtUname.Text & "'and pword='" & txtPassword.Text & "'"
command = New SqlCommand(strsql, conn)
conn.Open()
Catch ex As Exception
Response.Write(ex.Message)
End Try
i = command.ExecuteScalar()
If i <> 1 Then
Response.Redirect("e:\dotnet\authenticationdenied.aspx")
Else
Response.Redirect("e:\dotnet\timesheet.aspx")
Response.Redirect("timesheet?n1" & txtUname.Text)
End If
Bookmarks