Link to home
Start Free TrialLog in
Avatar of Member_2_1242703
Member_2_1242703

asked on

DataReader EOF Help in VB.NET

I'm trying to cycle through a database table (kind of like EOF in VB6) and then do something for each entry I find. What am I doing wrong?
myConStringReader = "Data Source=ussrm-netsql\netdata;" & _
                    "Initial Catalog=PhysicalInventory;" & _
                    "Integrated Security=SSPI"
        Dim mySelectQueryReader As String = "SELECT * FROM tblDataEntry where WMSQty IS NULL"
        Dim myConnectionReader As New Data.SqlClient.SqlConnection(myConStringReader)
        myCommandReader = New Data.SqlClient.SqlCommand(mySelectQueryReader, myConnectionReader)
        myConnectionReader.Open()
        myReader = myCommandReader.ExecuteReader
        While myReader.Read()
            strPN = CType(Session.Item("reader"), Data.SqlClient.SqlDataReader)("PartNumber").ToString
            Dim myConnectionBBB4 As New SqlClient.SqlConnection
            Dim myCommandBBB4 As New SqlClient.SqlCommand
            myConnectionBBB4.ConnectionString = "Data Source=ussrm-WMSSQL;" & _
                             "Initial Catalog=ASCTrac;" & _
                             "Integrated Security=SSPI"
            myCommandBBB4.Connection = myConnectionBBB4
            myCommandBBB4.CommandText = "SELECT SUM(QTYTOTAL) FROM LOCITEMS where ITEMID like '" & strPN & "'"
            myConnectionBBB4.Open()
            wmsqty = myCommandBBB4.ExecuteScalar()
            myConnectionBBB4.Close()
 
 'DO SOMETHING
        End While

Open in new window

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

which problem do you have?
ASKER CERTIFIED SOLUTION
Avatar of CodeJunky
CodeJunky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial