Using two Datareader

Discussion in 'ASP .Net' started by Randall, Oct 28, 2003.

  1. Randall

    Randall Guest

    Hi all,
    I have to use two separate queries in an .aspx file.
    What is the way to use two Datareaders for that.

    Or is there any other solution?

    Any kind of help or coding or documentation is
    appreciated.

    Thanks,
    Randall
    Randall, Oct 28, 2003
    #1
    1. Advertising

  2. You could use a query that returns 2 resultsets.
    When you're done with the first one, call NextResult.
    Here's more info:
    http://msdn.microsoft.com/library/d...qlclientsqldatareaderclassnextresulttopic.asp

    Or you could use one or two DataSets instead of DataReaders.
    Here's more info:
    http://msdn.microsoft.com/library/d...ref/html/frlrfsystemdatadatasetclasstopic.asp

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com




    "Randall" <> wrote in message
    news:042e01c39da9$edd18130$...
    > Hi all,
    > I have to use two separate queries in an .aspx file.
    > What is the way to use two Datareaders for that.
    >
    > Or is there any other solution?
    >
    > Any kind of help or coding or documentation is
    > appreciated.
    >
    > Thanks,
    > Randall
    Steve C. Orr [MVP, MCSD], Oct 28, 2003
    #2
    1. Advertising

  3. Randall

    Guest Guest

    You can use

    dim comm as sqlcommand = new sqlcommand("select * from
    query1","select * from query2")

    dim dataset1 as dataset= new dataset(comm,connectionstring)

    dim da as new dataadapter

    da.fill(comm)

    da.table(0) for first query table
    da.table(1) for second query table

    Thanks
    Ninan J


    >-----Original Message-----
    >Hi all,
    >I have to use two separate queries in an .aspx file.
    >What is the way to use two Datareaders for that.
    >
    >Or is there any other solution?
    >
    >Any kind of help or coding or documentation is
    >appreciated.
    >
    >Thanks,
    >Randall
    >.
    >
    Guest, Oct 28, 2003
    #3
  4. Randall

    Randall Guest

    Thanks Ninan.
    What if I have to use same table in both the queries?
    Any suggestion?

    Regards,
    Randall.
    >-----Original Message-----
    >You can use
    >
    >dim comm as sqlcommand = new sqlcommand("select * from
    >query1","select * from query2")
    >
    >dim dataset1 as dataset= new dataset

    (comm,connectionstring)
    >
    >dim da as new dataadapter
    >
    >da.fill(comm)
    >
    >da.table(0) for first query table
    >da.table(1) for second query table
    >
    >Thanks
    >Ninan J
    >
    >
    >>-----Original Message-----
    >>Hi all,
    >>I have to use two separate queries in an .aspx file.
    >>What is the way to use two Datareaders for that.
    >>
    >>Or is there any other solution?
    >>
    >>Any kind of help or coding or documentation is
    >>appreciated.
    >>
    >>Thanks,
    >>Randall
    >>.
    >>

    >.
    >
    Randall, Oct 29, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    1,505
  2. Replies:
    0
    Views:
    427
  3. Replies:
    0
    Views:
    410
  4. Wayne  Wengert

    Using a DataReader in VS NET

    Wayne Wengert, Jan 22, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    359
  5. GenxLogic
    Replies:
    3
    Views:
    1,240
    andrewmcdonagh
    Dec 6, 2006
Loading...

Share This Page