Looking at the following code.
Code:
            Using cnxn2 As New SqlClient.SqlConnection(cnxnstring)
                cnxn2.Open()
                Using sql2 As New SqlClient.SqlCommand
                    sql2.CommandText = "SELECT * FROM PODETAIL WHERE [PONUM] = " & glbPONum
                    sql2.CommandText &= " AND [STATUS] = " & "'" & "A" & "'"
                    sql2.CommandText &= " ORDER BY [LINENUM]"
                    sql2.CommandType = CommandType.Text
                    sql2.Connection = cnxn2
                    Dim reader2 As SqlDataReader
                    reader2 = sql2.ExecuteReader
                    Using reader2
                        Dim totalreceived As Integer = 0
                        If reader2.HasRows Then
                            While reader2.Read
                                x = CShort(reader2("LINENUM") - 1 & "")
                                txtPart(x).Text = reader2("partnum") & ""
                                txtDescription(x).Text = Trim(reader2("NOTES")) & ""
                                txtDeliveryDate(x).Text = VB6.Format(reader2("DELIVERYDATE"), "mm/dd/yyyy") & ""
                                txtQuantity(x).Text = reader2("QUANTITY") & ""
                                txtUnitPrice(x).Text = reader2("UNITPRICE") & ""
                                txtUOM(x).Text = Trim(reader2("UOM")) & ""
                                '
                                '--------------
                                'get receipts
                                '--------------
                                '
                                Using sql3 As New SqlClient.SqlCommand
                                    sql3.CommandText = "SELECT * FROM RECEIPTHISTORY WHERE [PONUMBER] = " & CInt(glbPONum)
                                    sql3.CommandText &= " AND [PARTNUMBER] = " & "'" & reader2("partnum") & "'"
                                    sql3.CommandType = CommandType.Text
                                    sql3.Connection = cnxn2
                                    Dim reader3 As SqlDataReader
                                    reader3 = sql3.ExecuteReader
                                    Using reader3
                                        If reader3.HasRows Then
                                            totalreceived = 0
                                            While reader3.Read
                                                totalreceived = totalreceived + reader3("QUANTITY")
                                            End While
                                            lblQtyRcvd(x).Text = CStr(totalreceived)
                                        Else
                                            lblQtyRcvd(x).Text = "0"
                                        End If
                                    End Using
                                End Using
                                '===============
                            End While
                        End If
                    End Using
                End Using
            End Using
            '===============
when it gets to this line:
Code:
reader3 = sql3.ExecuteReader
I get an error : There is already an open DataReader associated with this command which must be closed first.

I might add that I get the error AFTER the code has executed once. So, it is tripping when going through the While Loop the 2nd time.

I tried adding a reader3.close after the using. That didn't work. I tried moving the reader3 Dim statement outside the While loop and that didn't work either.

ideas?