piscis Posted August 1, 2003 Posted August 1, 2003 How to �REFRESH� a database. Does anyone have the code for refreshing a OleDB .mdb database? On a Tabcontrol, Tab1 page I insert a record into a Datagrid.1 and click update using dataAdapter1-dataSet1 combination. No problem here. On the Tab2 page I have the same database connection but with a Parent-Child relationship showing a few textboxes and a Datagrid.2 with dataAdapter2-dataSet2. The problems comes with the Record that was inserted in Tab1 not being shown in Datagrid.2 in Tab2. When I quit the application and started it again the Record is indeed shown in Datagrid.2 in Tab2. What should I do to refresh Datagrid.2 so the records inserted in Tab1 appears immediately. I tried these but none of the code below works. Me. Datagrid.2_PositionChanged() Datagrid.2.Refresh() Andy Quote
*Experts* Nerseus Posted August 1, 2003 *Experts* Posted August 1, 2003 It sounds like you're binding Tab2 to a different DataSet than Tab1? Why? If you bind to both, updates in one will show in the other (but you'd have to bind to the right row, or the updates on Tab2, in individual controls, may still show record 1). A DataAdapter/DataSet is not sync'd with the database. If you make changes they will not refresh automatically. You must do the refreshing. Each DataSet is also stored in memory separately and they are not sync'd either. So even though they were filled with the same query, once that data was loaded into each DataSet, they became their own distinct repositories. I'd suggest using one DataSet in your case (seems right from the limited info you gave). If not, changes to one DataSet will have to be manually sync'd with the other, either by merging one DataSet with another, or refilling one (or all) datasets from the database (a lot more network traffic). -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.