locked
Can I execute a update command to a dataset without importing the whole table data into the dataset? RRS feed

  • Question

  • I have a Visual Basic program which needs to insert into this huge table in SQL server 2008(> few million rows).

    Tuesday, June 20, 2017 6:18 AM

Answers

  • Jess,

    If you use a dataset (in fact the tables) then the rows get a rowstate if there are changes (New, Changed, Deleted). 

    Only rows which have not the rowstate "unchanged" are updated. 


    Success
    Cor



    Tuesday, June 20, 2017 9:14 AM

All replies

  • Jess,

    If you use a dataset (in fact the tables) then the rows get a rowstate if there are changes (New, Changed, Deleted). 

    Only rows which have not the rowstate "unchanged" are updated. 


    Success
    Cor



    Tuesday, June 20, 2017 9:14 AM
  • Hello,

    For millions of records it's not wise attempting to load this many records. I would suggest providing a method e.g. a filter to slim down how many rows are returned where the user interface provides controls to filter then in turn you execute an SQL SELECT WHERE statement to return the rows of data. If the filter might return a large set of records you need to consider response time hence look at paging a DataGridView.  The following code sample show a simple example of paging.

    If you needed to do write operations look at SqlClient data provider SqlBulkCopy, simple example.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, June 20, 2017 10:19 AM
  • No you only need add the rows that are to be updated. But if you are importing data and exporting to SQL Server, where is this data coming from? For this type of operation you may want to consider using the SqlBulkCopy Class.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Tuesday, June 20, 2017 2:10 PM