locked
How do I insert data from a datagridview into a SQL table? RRS feed

  • Question

  • I have a dataset table which contains column information for a number of sql structures stored in a central database.  My code gets system info from a new db and looks for where there are new columns.  I want to add the new column info to the table in the central db.

    I have a sql query which fills a datagridview with the new info and the user can add descriptions to some of the columns.  I then want to take all the data displayed in the datagridview and insert it into the dataset.

    I've played around with an Insert Table adapter query and tried a few other things and I can't find anything online or in my manuals to help me progress.

    Any ideas?

    Monday, October 4, 2010 3:07 PM

Answers

  • Hello SophieRose,

    For inserting new item in the DataGridView to the binded database table, you may refer to this link: How to refresh a DataGridView in VB 2008, it almost the same scenario as yours.

    For more information, updating both dataGridView when dataSource (mainly DataBase) is changed and updating DataBase when DataGridView is changed, the following threads give a clear conclusion of the two direction updates.

    http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/078e1a68-4aff-4693-bde9-240d96230a07

    You may not find an example that will exactly solve your issue but all the logic and technique you need is in there.

    Regards,
    Helen Zhou


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Thursday, October 14, 2010 8:45 AM
    Monday, October 11, 2010 3:00 AM

All replies

  • I'm working with C# by the way.
    Monday, October 4, 2010 3:14 PM
  • Hello SophieRose,

    For inserting new item in the DataGridView to the binded database table, you may refer to this link: How to refresh a DataGridView in VB 2008, it almost the same scenario as yours.

    For more information, updating both dataGridView when dataSource (mainly DataBase) is changed and updating DataBase when DataGridView is changed, the following threads give a clear conclusion of the two direction updates.

    http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/078e1a68-4aff-4693-bde9-240d96230a07

    You may not find an example that will exactly solve your issue but all the logic and technique you need is in there.

    Regards,
    Helen Zhou


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Thursday, October 14, 2010 8:45 AM
    Monday, October 11, 2010 3:00 AM