Some weeks ago, I posted a question and instead of help received a rather toxic scree (that is the word I want to use and is appropriate to the action) from a alleged authority, instead of any help or useful suggestions.
I spent quite a bit of time on this and eventually figured out what was required. It was nothing complex, or particularly tricky, and could have been addressed by anyone who has any knowledgeable advice. I was able to finally resolve the issue myself.
The original issue was that I had a DGV bound to a table and I wanted to add/delete and modify records in the dgv and have those changes reflected in the table (ACCESS). I had looked at numerous methods and found two that were promising.
The first was a commonly used method based on a routine requiring that the whole dgv be processed in a loop containing a query, and using. I was able to make this method work, but not well.Code:Command.ExecuteNonQuery()
The second method was based on the adapter.Update command and, at the time, I was completely unable to make this method work at all.
What was required was to set the correct properties and use the code below.
Code:Private Sub fileScan_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown LoadGrid() SetState() End SubCode:Private Sub LoadGrid() SetQuery() If RecordCount > 0 Then dgvList.DataSource = FileMaster.ListDataSet.Tables(0) dgvList.Rows(0).Selected = True FileMaster.ListAdapter.UpdateCommand = New OleDbCommandBuilder(FileMaster.ListAdapter).GetUpdateCommand End If End SubThe key to the whole process is the line:Code:Private Sub SetQuery() #Region "Establish Connection and execute query" FileMaster.ScanMasterQuery("SELECT colScan,colScanPath FROM lkpScan") #End Region End Sub
found in LoadGrid().Code:FileMaster.ListAdapter.UpdateCommand = New OleDbCommandBuilder(FileMaster.ListAdapter).GetUpdateCommand
In my previous post my intelligence was questioned for even using this line. It turns out that one can do just about anything wanted to a dgv using this method.
At the end of the day, it is really good that there is someone that is willing to assist those of us who might not be experts. Most of the experts here do indeed provide that wonderful service. However, there are some alleged experts who often have nothing to offer but to question my intelligence for even asking a question, and then offer NO useful information, or gibberish instead of useful information.




