Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to traverse through the records using sql datareader

how to traverse through the records using sql datareader

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasemysqlsql-server
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nerzhul86
    wrote on last edited by
    #1

    We are doing a project in asp.net 2.0 with sql server 2005,we need to move to the next record at the click of a button.We are using an sql datareader,we have one button 'show',to show each record,and in the page load, the following code is there: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load regid.Text = "1" mysql = "select que_bank.que_no,que_bank.ans,testquestions.ans from testquestions,que_bank where que_bank.que_no=testquestions.que_no and testquestions.reg_id='" & regid.Text & "'" cmd.CommandText = mysql myconn.Open() objdr = cmd.ExecuteReader() End Sub Protected Sub show_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles show.Click objdr.Read() queno.Text = objdr.GetValue(0) cans.Text = objdr.GetValue(1) urans.Text = objdr.GetValue(2) End Sub Can anyone help us?

    A L 2 Replies Last reply
    0
    • N nerzhul86

      We are doing a project in asp.net 2.0 with sql server 2005,we need to move to the next record at the click of a button.We are using an sql datareader,we have one button 'show',to show each record,and in the page load, the following code is there: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load regid.Text = "1" mysql = "select que_bank.que_no,que_bank.ans,testquestions.ans from testquestions,que_bank where que_bank.que_no=testquestions.que_no and testquestions.reg_id='" & regid.Text & "'" cmd.CommandText = mysql myconn.Open() objdr = cmd.ExecuteReader() End Sub Protected Sub show_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles show.Click objdr.Read() queno.Text = objdr.GetValue(0) cans.Text = objdr.GetValue(1) urans.Text = objdr.GetValue(2) End Sub Can anyone help us?

      A Offline
      A Offline
      anilpal
      wrote on last edited by
      #2

      Hi, Can u use DataTable in place of DataReaader?

      Regards Anil Pal

      1 Reply Last reply
      0
      • N nerzhul86

        We are doing a project in asp.net 2.0 with sql server 2005,we need to move to the next record at the click of a button.We are using an sql datareader,we have one button 'show',to show each record,and in the page load, the following code is there: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load regid.Text = "1" mysql = "select que_bank.que_no,que_bank.ans,testquestions.ans from testquestions,que_bank where que_bank.que_no=testquestions.que_no and testquestions.reg_id='" & regid.Text & "'" cmd.CommandText = mysql myconn.Open() objdr = cmd.ExecuteReader() End Sub Protected Sub show_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles show.Click objdr.Read() queno.Text = objdr.GetValue(0) cans.Text = objdr.GetValue(1) urans.Text = objdr.GetValue(2) End Sub Can anyone help us?

        L Offline
        L Offline
        logiclabz
        wrote on last edited by
        #3

        I hope this is a bad practice.. In your code connection is open and seems to be never closed. Best thing to do is to use Paging in Sql server with @rowsPerPage being 1 and @pageNum being row no. hope u understand the concept

        ----------------- logiclabz

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups