Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Already an open DataReader?
Message
From
15/01/2013 14:33:23
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Already an open DataReader?
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01562745
Message ID:
01562745
Views:
46
I'm getting a 'Already as open DataReader of that name' error on the following code:
    Using sconn As New SqlConnection(ConnString)
      Try
        PswrdTries = PswrdTries + 1
        If PswrdTries > 2 Then
          Me.Close()
        End If
        sconn.Open()
        Dim msql1 As String = "Select * from CATDecode where DecName = 'PASSWORD'"
        Using ms1 As New SqlCommand(msql1, sconn)
          Using ds1 = ms1.ExecuteReader
            If ds1.Read Then
              If Trim(ds1.Item("DecValue").ToString.ToUpper) <> Trim(txtPassWord.Text.ToUpper) Then
                MsgBox("Password does not match" & vbCrLf & "One try left", vbOKOnly + vbCritical, "Incorrect Password")
              Else
                Dim msql2 As String = "Select * from CATDecode where DecName = 'SUBBANK'"
                Using ms2 As New SqlCommand(msql2, sconn)
** Error occurs on next statement **
                  Using ds2 = ms2.ExecuteReader
                    If ds2.Read() Then
                      TestSub = ds2.Item("DecValue").ToString.Substring(4, ds2.Item("DecValue").ToString.Length)
                    End If
                  End Using
                End Using
              End If
            End If
          End Using
        End Using
        sconn.Close()
      Catch ex As Exception
        sconn.Close()
        MsgBox("Sql Exception:  " & ex.Message)
      End Try
    End Using
What am I missing?
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Next
Reply
Map
View

Click here to load this message in the networking platform