DataGridView Update

后端 未结 3 1787
甜味超标
甜味超标 2021-01-24 15:32

I\'m using 2005 Windows Forms in C#. I\'ve only been working at this for a day, so go easy please.

I\'d like to have a submit button that saves changes to a DataGridVie

相关标签:
3条回答
  • 2021-01-24 16:14

    Update on a table-adapter needs a DataSet.

    You need to instantiate a scDB DataSet with the table, update that table and call to Update for the table-adapter.

    0 讨论(0)
  • 2021-01-24 16:18

    If you've configured the proper TableAdapter to go with the DataTable specified (Right-Click on the TableAdapter section and select "Configure...'), you'll have a wide variety of options.

    After doing this on my own DataTables I'm able to update by

    • Strongly Typed DataTable
    • DataSet
    • DataRow DataRow() - Array of DataRows if multiple require updating
    • Individual Columns (provided you have unique key to tie the row to)
    0 讨论(0)
  • 2021-01-24 16:20

    Sam,

    the update needs a table so you could try something like:

    TableType table = (TableType) stagingGrid.DataSource;
    myStagingTableAdapter.Update(table);
    

    where you'll have to substitute TableType with something appropriate.

    But a better approach would be to use drag-and-drop and learn form the code.

    1. Select Data|View Datasources. Your dataset should be visible in the DataSources Window.
    2. Drag a table to a (new) form. VS2005 will add a load of components and a few lines of code.

    The form will now have a instance of the dataset and that is your reference point for Adapter.Fill and .Update methods.

    0 讨论(0)
提交回复
热议问题