Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 28th, 2004, 11:02 AM
Registered User
 
Join Date: Apr 2004
Location: , , .
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()
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.