Insert all data of a datagridview to database vb.net

后端 未结 2 1296
北荒
北荒 2021-01-23 06:43
    Dim Con As OleDbConnection = New OleDbConnection(\"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Music_Sales_Database.mdb;\")
    Dim Com As OleDbCommand
    Dim Sale         


        
2条回答
  •  醉话见心
    2021-01-23 07:31

    You're making things more complex than they need to be. Just create a DataTable and bind it to the grid. When it comes time to save the data, it takes one call to the Update method of a data adapter to save the lot. You use the same data adapter to generate the schema in the DataTable by calling FillSchema and then use a command builder to generate the INSERT command or you can build the schema and the INSERT command manually. Here are some examples:

    http://www.vbforums.com/showthread.php?469872-Retrieving-and-Saving-Data-in-Databases&highlight=

提交回复
热议问题