Dataadapter update not updating database
As per your suggestion -1) How could I use a Data View to incorporate the 'Employee Name' when it is not part of the underlying datatable upon which the dataview would be made and2) This Datagridview allows the user to Update, Add and delete Data, if a Data View can resolve the sort on display value requirement then will it also allow for Updating Adding and Deleting Data in the Data Grid View? 3) Have you any example code depicting similar solution.
Add(New Object() ) 'Data View to sort the items Dim dv As New Data View dv. Sort = "Des" Dim cb As Data Grid View Combo Box Column = Me. Data Source = dt1 End Sub Hello River Guy, Thanks for your reply and code example. Automatic 'Data Table for Combo Box source Dim dt2 As New Data Table dt2. To set this up, instead of binding my Data Grid View directly to the Data Table, I bind it to a Data View based off of the Data Table. On the Selected Index Changed event of your Combo Box, you can get the sort column, and change the . Step 2Click on the pin button on right-up side of Data Grid View and click add project Data Source. If you update any cell and click the update button, then the database will be updated.
To delete, select the rows and then press the Delete key and click the update button; the rows will be deleted.
It won't be elegant code by any means, but off the top of my head, that's the only way I can think of at the moment to accomplish this.
Modify your Select query for your Data Adapter which fills the Data Table for your main table. Modify your Insert, Update and Delete commands for your Data Adapter to supply just the employee_id to your parameters collection instead of the concatenated value.
With Auto Sort turned on it sorts on the cell value data rather than the 'Display Value' which is meaningless to the user.
Eg., the cell value (combobox) is the 'employee_id' from the bound datasource whilst the display value being the 'employee name' from a lookup table i.e., the employee table.
So, instead of having "1" as the value for Smith, the value would be something like "Smith00001."2. Last Name RIGHT('0000' CONVERT(VARCHAR(6), t.employee_id),5) AS Employee FROM transactions t INNER JOIN employees e ON......"3.