Hi,
I'm new to VB.NET..I'm developing a login page...im getting this error..
System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is Open, Fetching. at System.Data.OleDb.OleDbCommand.ValidateConnectionA ndTransaction(String method, Int32& localState) at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReader() at bt.index.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\bt\index.aspx.vb:line 56
The code in .aspx.vb page is
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
Try
Dim MyConn As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings( "strConn"))
Dim strVisitor As String
Dim visitorCmd As OleDbCommand
Dim vRdr As OleDbDataReader
strVisitor = "select max(v_id) from visitor"
visitorCmd = New OleDbCommand(strVisitor, MyConn)
MyConn.Open()
Dim old_visitor As Integer
Dim new_visitor As Integer
vRdr = visitorCmd.ExecuteReader()
While vRdr.Read()
If Not IsDBNull(visitorCmd.ExecuteReader()) Then
old_visitor = vRdr.Item(0)
End If
End While
new_visitor = old_visitor + 1
lblvisitor.Text = new_visitor
MyConn.Close()
Catch ex As Exception
Response.Write(ex)
End Try
End If
End Sub
Your help will be much appreciated
--
Message posted via http://www.dotnetmonster.com