Re-Post

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I tried to post this about an hour ago but it never appeared on the NG so I
am trying again.

I have a set of aspx pages in which I am having some strange problems
relating to a connection. I'll focus on just one of the problems here. (See
code below). If I include the Close method for the connection as shown
below, the ExecuteScalar fails with an error that the connection is Closed.
If I comment out the Close, it works? I don't understand what is happening
here?


================= Code =================
If CommonClass.myConn.State.Closed Then

CommonClass.CreateConnection()

CommonClass.myConn.Open()

End If

Dim strSQL As String

strSQL = "Select Count(BandID) From JudgeEvals Where JudgeID = " &
Session("CurrJudgeID") _

& " AND EventID = '" & Session("strCurrEventID") & "' AND BandID = " &
Session("CurrBandID")

Dim cmd1 As New OleDb.OleDbCommand(strSQL, CommonClass.myConn)

Dim intRecCount As Int16 = cmd1.ExecuteScalar

CommonClass.myConn.Close <==== Problem here

If intRecCount > 0 Then 'This unit has already evaluate this judge at this
event

lblInfo.Text = "This band has already evaluated this judge for this event!"

lblInfo.Visible = True

Exit Sub

End If
 
Back
Top