Results 1 to 3 of 3

Thread: Move to a next record using ado.net

  1. #1
    ryoka012 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Oct 2011
    Posts
    2
    Reputation
    0

    Move to a next record using ado.net

    How can i create a command that can use a ado.net to move in a next record using stored procedure with parameters.
    I am using a sql 2005.


    Thanks.
    Last edited by ryoka012; 06-14-2012 at 6:31 AM.

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,331
    Reputation
    1543
    It depends exactly what you mean by moving to the next record. With ADO.NET, there are basically three ways to work with your data:

    1. Call ExecuteReader on your command object to create a data reader, then call Read on that data reader in a loop to read the result set of your query row by row. A data reader is read-only and forward-only, so if you want to be able to use the data again later, you need to store it somewhere yourself.

    2. After calling ExecuteReader, you can pass the data reader to the Load method of a DataTable to load the result set into that DataTable. You can then use that DataTable in whatever way you like.

    3. If you want to edit and save the data then you should use a data adapter to populate a DataTable by calling its Fill method. After editing the data as required, you can call Update on the data adapter to save the changes.

    If you choose one of the options that involves a DataTable, you can bind it to a BindingSource and bind that to a DataGridView or individual TextBoxes, etc. The BindingSource exposes all the rows as a list and the selected row via its Current property. You can navigate the data using the MoveFirst, MovePrevious, MoveNext and MoveLast methods. You can also associate the BindingSource with a BindingNavigator, which is a specialised ToolStrip with buttons for each of those methods and more.

  3. #3
    ryoka012 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Oct 2011
    Posts
    2
    Reputation
    0
    Thanks jmcilhinney got it now.

Bookmarks

Posting Permissions

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