vb.net database programming

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sandy

    vb.net database programming

    hi friends...
    i am new to VB.NET.i was trying to read some data from the database
    using code,
    and display that in 2 textboxes.i was able to get only the first row.
    i used ExecuteReader() function of SqlCommand class and read()
    function to read data..
    i have put a button on the form to advance the records..
    in that click method i have called the read() function...
    but it's not moving to the next record...even after clicking the
    button...
    please help me anyone...
    thanks and regards...
    sandeep...

  • rowe_newsgroups

    #2
    Re: vb.net database programming

    Could you post your code? That way we can see what is going on.

    Thanks,

    Seth Rowe


    sandy wrote:
    hi friends...
    i am new to VB.NET.i was trying to read some data from the database
    using code,
    and display that in 2 textboxes.i was able to get only the first row.
    i used ExecuteReader() function of SqlCommand class and read()
    function to read data..
    i have put a button on the form to advance the records..
    in that click method i have called the read() function...
    but it's not moving to the next record...even after clicking the
    button...
    please help me anyone...
    thanks and regards...
    sandeep...

    Comment

    • sandy

      #3
      Re: vb.net database programming

      Thanks Seth Rowe...

      i will paste the code...


      Protected Sub Page_Load(ByVal sender As Object, ByVal e As
      System.EventArg s) Handles Me.Load

      cn = New SqlConnection(" Data Source=VIDYAMAY I18\SQLEXPRESS; Initial
      Catalog=model;I ntegrated Security=True")

      sqlcmd = New SqlCommand()
      sqlcmd.CommandT ext = "select * from infotab"
      sqlcmd.Connecti on = cn
      cn.Open()
      sqlreader = sqlcmd.ExecuteR eader()

      End Sub

      Protected Sub Button1_Click(B yVal sender As Object, ByVal e As
      System.EventArg s) Handles nextbutton.Clic k

      sqlreader.Read( )
      txtname.Text = sqlreader(0)
      txtaddress.Text = sqlreader(1)

      End Sub

      Protected Sub Page_Unload(ByV al sender As Object, ByVal e As
      System.EventArg s) Handles Me.Unload

      cn.Close()

      End Sub


      i tried to fetch the records as i press the button and display the data
      in textboxes...

      thanks and regards
      sandeep...

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: vb.net database programming

        Sandy,

        Just use Databinding that makes it more easy and more from this time.



        I hope this helps,

        Cor

        "sandy" <sandy4grp@gmai l.comschreef in bericht
        news:1160831843 .705145.254210@ k70g2000cwa.goo glegroups.com.. .
        hi friends...
        i am new to VB.NET.i was trying to read some data from the database
        using code,
        and display that in 2 textboxes.i was able to get only the first row.
        i used ExecuteReader() function of SqlCommand class and read()
        function to read data..
        i have put a button on the form to advance the records..
        in that click method i have called the read() function...
        but it's not moving to the next record...even after clicking the
        button...
        please help me anyone...
        thanks and regards...
        sandeep...
        >

        Comment

        Working...