I have an UPDATE sql command that modifies a Date/Time field in a particular table. This table has two keys, ProductionCode and TestTime, which is what is being modified. The Production Code never changes for a particular record, but often a user will find that they entered the wrong test time and need to change it.
I have the updated time which I can retrieve from the datagrid, however, I need to select the right record to change. In order to do that, one of my where criteria has to be the current time that that record is set at in the database.
Currently, I keep an array of old times, which are updated whenever an UPDATE command is run. So in the WHERE block of the sql command, the old time is used. Once its updated in the database, then I update the time array. The difficulties come in when times are entered out of order, or when the datagrid is sorted on a different field than the time. I have to keep track of what order all the old times are in corresponding to the data grid rows, and its caused a number of bugs in the past. Currently it works fine, but its delicate at best.
So what I'm really looking for is a better solution. Should I just store the results of the SELECT statement that is used to populate the UI, and rely on them? Currently, the only place my database results go, is directly into the datagrid. Or is there another way? I have avoided automatic data binding in favor of manually using SQL commands because my datagrids are dynamically configured and use different schemas from one load to the next, and the only columns guaranteed to be there are the ProductionCode and the TestTime.