Home>

I am creating a tool to store the data displayed in DataGridView in the database of SQLserver.

By the way, I tried TableAdapter, but I was not sure about it halfway, so I was frustrated.

Also, some of the reference sites take data from the database once, input it into DataGridView, and store the edited DataGridView in the database, but there are many ways to store the existing DataGridView in the database. Is n’t it? Please teach me.

Additional
This is the site that I used as a reference.
Link 1
Link 2
Link 3
Link 4

  • Answer # 1

    Articles 1 to 3 that are referenced seem to work by writing code with a considerable amount of self-help, but if you want to create an app with a standard configuration using the wizard of Visual Studio, such a necessity is necessary Without a single table, you can create an app without having to write a single line of code.

    In Article 4, I think that the questioner seems to be straying and should not be seen. In the answer, "Generally, it is reflected in the database by passing DataSet with Update method of TableAdapter".

      

    Is there any way to store an existing DataGridView in the database?

    Is it without DataSet/DataTable + DataAdapter? Do n’t think about that. It is a waste of time and effort.

    DataGridView is a UI, and the most important role is DataSet/DataTable + DataAdapter. It is better to think that it is impossible without it.

    Since the contents of the following articles do not need to be read, only look at Figure 1 and Figure 2. You can see at a glance what I said above.

    Clarification for DB designers ADO.NET, Part 1
    https://msdn.microsoft.com/en-us/library/cc482903.aspx

    DataGridView is not shown, but it is bound to a DataSet and used by the user to edit the contents of the DataSet.

    Try creating a standard app using the Visual Studio wizard.

    DB seems to be SQL Server, so the following tutorial

    Tutorial: Saving data to a database (single table)
    https://msdn.microsoft.com/en-us/library/0f92s97z(v=vs.120).aspx

    10 lines in a row !! Unconnected data access (ADO.NET) (C #)
    https://code.msdn.microsoft.com/windowsdesktop/10-ADONET-C-cbfe7688

    If you create a typed DataSet + TableAdapter using the Visual Studio data source configuration wizard as shown in

    ... and make an application using it, the application has the structure shown in the figure on the following page. But you can make it almost without writing your own code.

    Connecting to data in a Windows Forms application
    https://msdn.microsoft.com/en-us/library/wxt2cwcc(v=vs.120).aspx

    If you get used to the operation, you should be able to make it in less than 10 minutes. The problem like this time will not be bothered, and the development man-hours should decrease drastically. Maintenance man-hours should also be reduced. Please try.