Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



ExecuteReader requires an open and available Connection.

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 03-02-2009
Member
 
Join Date: Jan 2009
Posts: 22
ExecuteReader requires an open and available Connection.
  

Hi,

I have a login page connected to SQL database that gives me error.

Quote:
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

Reply With Quote
  #2  
Old 03-02-2009
Member
 
Join Date: Jan 2009
Posts: 44
Re: ExecuteReader requires an open and available Connection.

Try using the try & catch for ==>> Move i = command.ExecuteScalar()

Problem has to be with conn.open()

also set a break point on catch line.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "ExecuteReader requires an open and available Connection."
Thread Thread Starter Forum Replies Last Post
Windows 8 wifi requires manual connection every time Dėfrim Operating Systems 6 10-09-2013 10:38 AM
MTNL requires 20 signature for FTTH connection Lord of speech India BroadBand 3 17-07-2013 06:43 PM
prince of persia forgotten sands requires net connection nandan1770 Video Games 1 13-07-2010 04:29 PM
Nokia 6301 requires lot of time to open inbox MAGAR Portable Devices 5 17-12-2009 08:23 PM
Change AD user password via LDAP - requires SSL Connection? Kaysel Window 2000 Help 2 08-08-2008 04:19 AM


All times are GMT +5.5. The time now is 12:43 PM.