Results 1 to 4 of 4

Thread: [RESOLVED] only getting results from first select in stored procedure using datareader

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    96

    Resolved [RESOLVED] only getting results from first select in stored procedure using datareader

    And I like the speed of the datareader over a datatable, so I'd like to make this work! Using VB.NET 2005. All the prior responses to the same problem say to return to datareader or use a datatable. I have no idea what return to datareader means.

    Thanks!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: only getting results from first select in stored procedure using datareader

    The DataReader can only "point to" one result set at a time. The Read method will get the next record in the current result set. To move to the next result set you call the NextResult method. Just like Read, NextResult will return True or False, depending on whether there was another result set to move to.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: only getting results from first select in stored procedure using datareader

    Keep in mind that you can't back up, as well, so Datareaders are fast, but they are also forward only.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    96

    Re: only getting results from first select in stored procedure using datareader

    Its the right application. And I got it

    [code/]
    Try
    connect.Open()
    dread = cmdLotNumber.ExecuteReader
    While dread.Read()
    txtCharge.Text = CStr(dread(0))
    tooltype = CStr(dread(1))
    txtProcess.Text = CStr(dread(2))
    txtWafer.Text = CStr(dread(3))
    txtQuantity.Text = CStr(dread(4))
    End While
    dread.NextResult()
    While dread.Read
    txt1.Text = CStr(dread(0))
    txt2.Text = CStr(dread(1))
    txt3.Text = CStr(dread(2))
    txt4.Text = CStr(dread(3))
    txt5.Text = CStr(dread(4))
    'guarantee catch
    txt5.Text = CStr(dread(5))
    End While
    Catch
    Try
    dread.NextResult()
    Dim I As Integer = 0
    While dread.Read
    Tools(I) = CStr(dread(I))
    I += 1
    End While
    Catch
    End Try
    connect.Close()
    End Try
    [/code]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width