DataGrid + ador.recordset is showing 0 recordcount
Posted on 2003-11-17
I have a project that uses a datagrid to display two fields. The datasource is a disconnected ADOR recordset that I create at runtime. The user selects two items from a Treeview and clicks a button. When the button is fired I place the items into the recordset which are displayed in the datgrid. This all works fine untill the user deletes all of the records in the datagrid(This is allowed). When the user goes to add another two items to the now empty recordset the items are added but it is never reflected in the recordsets recordcount. Here is what I am doing, rdis is the datagrids datasource:
rDis.Fields(0).Value = Trim(Left(txtMapS.Text, (InStr(txtMapS, "(") - 1)))
rDis.Fields(1).Value = Trim(Left(txtMapA.Text, (InStr(txtMapA, "(") - 1)))
rDis.Fields(2).Value = (Left(sStageKeyACT, (InStr(sStageKeyACT, "%") - 1)))
The user can click the button all day and the only way the recordcount is updated is if I go to the datagrid and manualy delete a record, but the records are added and visible in the datagrid.
If I step through the code when the datagrid already has records the recordcount is incremented as soon I call addnew but after the record count has been brought to zero this is not the case. I have tried updating, refreshing and requerying both the datagrid and the recordset with no luck. If I even highlight one of the rows in the datagrid this also seems to somehow sync the data so that I get an accurate record count.
Can anyone help? I would even do something clunky like programaticaly select a row but have not figured out how.
Thanks for your time.