Results 1 to 2 of 2

Thread: ExecuteReader requires an open and available Connection.

  1. #1
    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.

    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

  2. #2
    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.

Similar Threads

  1. Windows 8 wifi requires manual connection every time
    By Dëfrim in forum Operating Systems
    Replies: 6
    Last Post: 10-09-2013, 10:38 AM
  2. MTNL requires 20 signature for FTTH connection
    By Lord of speech in forum India BroadBand
    Replies: 3
    Last Post: 17-07-2013, 06:43 PM
  3. Replies: 1
    Last Post: 13-07-2010, 04:29 PM
  4. Nokia 6301 requires lot of time to open inbox
    By MAGAR in forum Portable Devices
    Replies: 5
    Last Post: 17-12-2009, 08:23 PM
  5. Replies: 2
    Last Post: 08-08-2008, 04:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,052,898.47870 seconds with 17 queries