Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2004, 11:02 AM
Registered User
 
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Invalid attempt to Read when reader is closed.

Hi I corrected my code but again I am getting same error but at different place. I dont understand whats wrong here now. Please help.
Thanks
for loop...
str2 = "SELECT * FROM DATATYPE WHERE DataTypeID=1 AND PointID=" & pid
                Dim getrid As New OleDbCommand(str2, myconnection)
                myreader1 = getrid.ExecuteReader()
                While (myreader1.Read())
                    rid = myreader1(2)
                End While
                myreader1.Close()

                query1 = "SELECT * FROM BOREHOLEDATASOURCE WHERE RecordID=" & rid
                query2 = "SELECT * FROM BOREHOLEDATA WHERE RecordID=" & rid

                If cnt = 1 Then
                    com1.CommandText = query1
                    adapter1.Fill(dset1, "BHDATASOURCE")
                    com1.CommandText = query2
                    adapter1.Fill(dset1, "BHDATA")
                End If

                rownew = dset1.Tables("BHDATASOURCE").NewRow

                Dim get1 As New OleDbCommand(query1, myconnection)
                myreader1 = get1.ExecuteReader()
                While (myreader1.Read())

                    rownew("RecordID") = myreader1(0)
                    rownew("FundAgencyID") = myreader1(1)
                   ' Error Line
               ******* rownew("EngineeringID") = myreader1(2)*****
                    rownew("GeotechCoID") = myreader1(3)
                    rownew("DrillingCoID") = myreader1(4)
                    rownew("ProjectNameID") = myreader1(5)
                    rownew("HoleID") = myreader1(6)
                    rownew("ReportNo") = myreader1(7)
                    rownew("ContractNo") = myreader1(8)
                    rownew("GeofileNo") = myreader1(9)
                    rownew("DrillFileNo") = myreader1(10)
                    rownew("BridgeNo") = myreader1(11)
                End While
                strfa = "Select o.Name from ORGANISATIONNAME o, BOREHOLEDATASOURCE bds, FUNDAGENCY f where f.FundAgencyID = bds.FundAgencyID and o.OrgCatID=2 and bds.FundAgencyID=" & myreader1(1)
                strec = "Select o.Name from ORGANISATIONNAME o, BOREHOLEDATASOURCE bds, ENGINEERINGCOMPANY e where e.EngineeringID = bds.EngineeringID and o.OrgCatID=3 and bds.EngineeringID=" & myreader1(2)
                strgc = "Select o.Name from ORGANISATIONNAME o, BOREHOLEDATASOURCE bds, GEOTECHCOMPANY g where g.GeotechCoID = bds.GeotechCoID and o.OrgCatID=4 and bds.GeotechCoID=" & myreader1(3)
                strdc = "Select o.Name from ORGANISATIONNAME o, BOREHOLEDATASOURCE bds, DRILLINGCOMPANY d where d.DrillingCoID = bds.DrillingCoID and o.OrgCatID=3 and bds.DrillingCoID=" & myreader1(4)
                strpn = "Select pu.ProjectName from PROJECTNAMELOOKUP pu, BOREHOLEDATASOURCE bds where pu.ProjectNameID = bds.ProjectNameID and bds.ProjectNameID=" & myreader1(5)

                myreader1.Close()

                Dim comfa As New OleDbCommand(strfa, myconnection)
                myreader1 = comfa.ExecuteReader()
                While (myreader1.Read())
                    fname = myreader1(0) & ""
                End While
                myreader1.Close()


                'myreader1 = get1.ExecuteReader()
                'While (myreader1.Read())

                Dim comec As New OleDbCommand(strec, myconnection)
                ' Dim readerec As OleDbDataReader
                'myconnection.Close()
                'myconnection.Open()
                myreader1 = comec.ExecuteReader()
                While (myreader1.Read())
                    'Response.Write("string is " & readerec(0))
                    'Response.End()
                    ename = myreader1(0) & ""
                End While
                myreader1.Close()


                'myreader1 = get1.ExecuteReader()
                'While (myreader1.Read())

                Dim comgc As New OleDbCommand(strgc, myconnection)
                'Dim readergc As OleDbDataReader
                'myconnection.Close()
                'myconnection.Open()
                myreader1 = comgc.ExecuteReader()
                While (myreader1.Read())
                    'Response.Write("string is " & readerec(0))
                    'Response.End()
                    gname = myreader1(0) & ""
                End While
                myreader1.Close()


                'myreader1 = get1.ExecuteReader()
                'While (myreader1.Read())

                Dim comdc As New OleDbCommand(strdc, myconnection)
                'Dim readerdc As OleDbDataReader
                'myconnection.Close()
                'myconnection.Open()
                myreader1 = comdc.ExecuteReader()
                While (myreader1.Read())
                    'Response.Write("string is " & readerec(0))
                    'Response.End()
                    dname = myreader1(0) & ""
                End While
                myreader1.Close()


                'myreader1 = get1.ExecuteReader()
                'While (myreader1.Read())

                Dim compn As New OleDbCommand(strpn, myconnection)
                'Dim readerpn As OleDbDataReader
                'myconnection.Close()
                'myconnection.Open()
                myreader1 = compn.ExecuteReader()
                While (myreader1.Read())
                    'Response.Write("string is " & readerec(0))
                    'Response.End()
                    pname = myreader1(0) & ""
                End While
                myreader1.Close()


                myreader1 = get1.ExecuteReader()
                While (myreader1.Read())
                    rnew("RecordID") = myreader1(0)
                    rnew("FundAgc") = fname
                    rnew("EngComp") = ename
                    rnew("GeoComp") = gname
                    rnew("DrilComp") = dname
                    rnew("ProjName") = pname
                    rnew("HoleID") = myreader1(6)
                    rnew("RepNo") = myreader1(7)
                    rnew("ContractNo") = myreader1(8)
                    rnew("GeofileNo") = myreader1(9)
                    rnew("DrilfileNo") = myreader1(10)
                    rnew("BridgeNo") = myreader1(11)

                    dset1.Tables("BHDATASOURCE").Rows.Add(rownew)

                End While

                myreader1.Close()
                'myconnection.Close()
                'myconnection.Open()





Similar Threads
Thread Thread Starter Forum Replies Last Post
Read stream from USB Magnetic Card Reader tsadok Visual Basic 2005 Basics 8 September 3rd, 2008 03:02 PM
Invalid attempt to FieldCount when reader is close hwajunsong Crystal Reports 1 December 28th, 2005 01:18 PM
Invalid attempt to Read when reader is closed. nidy_online VS.NET 2002/2003 1 April 28th, 2004 02:19 AM
How to make stream reader read doc files? bcmaverik VB.NET 2002/2003 Basics 2 March 10th, 2004 10:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.