|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagridsdisplay data (access db) and when user double clicks on a record, another form shows up which allows modification/addition of data. The problem is when user accepts the changes made and gets back to datagrid. The information displayed is still the old info. How do I get the new information to display? Here is an example of the code used to update the data: objDataSet.Tables("Table").Rows(objCurrencyManager.Position).BeginEdit() objDataRow = objDataSet.Tables("Table").Rows(objCurrencyManager.Position) With objDataRow .Item("Field1") = Text1.Text End With objDataRow.AcceptChanges() objDataSet.Tables("Table").Rows(objCurrencyManager.Position).AcceptChanges() Shouldn't the data in the datagrid diplay the information that was entered in Text1.Text? Or is it that I'm doing something wrong? Many thanks for any replies!! MFleet,
I would try it by refreshing the datagrid. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassrefreshtopic.asp More worse is the acceptchanges in your code. It means that all the data in your dataset should be handled as been updated to the database. (You are not the first one who interprets this command wrong) :-) If means something as Accept changes as done.I hope this helps, Cor <mfleet1***@yahoo.ca> schreef in bericht Show quoteHide quote news:1150746935.759541.103340@u72g2000cwu.googlegroups.com... > Hello. I'm fairly new to VB.Net (2003). I'm using a datagrid to > display data (access db) and when user double clicks on a record, > another form shows up which allows modification/addition of data. The > problem is when user accepts the changes made and gets back to > datagrid. The information displayed is still the old info. How do I > get the new information to display? Here is an example of the code > used to update the data: > > objDataSet.Tables("Table").Rows(objCurrencyManager.Position).BeginEdit() > objDataRow = > objDataSet.Tables("Table").Rows(objCurrencyManager.Position) > > With objDataRow > .Item("Field1") = Text1.Text > End With > objDataRow.AcceptChanges() > objDataSet.Tables("Table").Rows(objCurrencyManager.Position).AcceptChanges() > > Shouldn't the data in the datagrid diplay the information that was > entered in Text1.Text? Or is it that I'm doing something wrong? > > Many thanks for any replies!! > Cor, I am not clear on what you mean by saying "If means something as
Accept changes as done." Does this mean you should AcceptChanges (update the database on disk) only when you are done and exit the DataGrid/program, and not during the editing process? Or, is it recommended to confirm/write/update a small portion of the data (ie, the row you just changed) right away? If the latter, how to you do that? Thanks. b**@datasync.com Cor Ligthert [MVP] wrote: Show quoteHide quote > MFleet, > > I would try it by refreshing the datagrid. > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassrefreshtopic.asp > > More worse is the acceptchanges in your code. > It means that all the data in your dataset should be handled as been updated > to the database. > > (You are not the first one who interprets this command wrong) > :-) > If means something as Accept changes as done. > > I hope this helps, > > Cor > > > <mfleet1***@yahoo.ca> schreef in bericht > news:1150746935.759541.103340@u72g2000cwu.googlegroups.com... > > Hello. I'm fairly new to VB.Net (2003). I'm using a datagrid to > > display data (access db) and when user double clicks on a record, > > another form shows up which allows modification/addition of data. The > > problem is when user accepts the changes made and gets back to > > datagrid. The information displayed is still the old info. How do I > > get the new information to display? Here is an example of the code > > used to update the data: > > > > objDataSet.Tables("Table").Rows(objCurrencyManager.Position).BeginEdit() > > objDataRow = > > objDataSet.Tables("Table").Rows(objCurrencyManager.Position) > > > > With objDataRow > > .Item("Field1") = Text1.Text > > End With > > objDataRow.AcceptChanges() > > objDataSet.Tables("Table").Rows(objCurrencyManager.Position).AcceptChanges() > > > > Shouldn't the data in the datagrid diplay the information that was > > entered in Text1.Text? Or is it that I'm doing something wrong? > > > > Many thanks for any replies!! > > Bob,
I cannot answer yes or no on your question, because when you do the database updates while editing it can be that you use it. But it has forever to do with update from a database as long as you don't do that, you normally should not use the acceptchanges. The acceptchanges can be used by instance in this sentence. myDataAdapter.Update(myDataTable.getchanges) Not that this gives any advantage but let assume. The dataadapter marks the rowstate of rows which are done as not changed. But the myDataTable.getchanges is a copy of the datatable, so it has to be done in the origanal as well. Therefore than the myDataTable.acceptchanges which means that those rows will not be updated again. I hope that this makes it a little bit clear because there are not much samples to give where it has to be used. It is not rare to use it, but there are very few places (a cascade update by instance can need it as well). Cor <b**@datasync.com> schreef in bericht Show quoteHide quote news:1150783832.084620.323740@c74g2000cwc.googlegroups.com... > Cor, I am not clear on what you mean by saying "If means something as > Accept changes as done." Does this mean you should AcceptChanges > (update the database on disk) only when you are done and exit the > DataGrid/program, and not during the editing process? Or, is it > recommended to confirm/write/update a small portion of the data (ie, > the row you just changed) right away? If the latter, how to you do > that? > > Thanks. > b**@datasync.com > > Cor Ligthert [MVP] wrote: >> MFleet, >> >> I would try it by refreshing the datagrid. >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassrefreshtopic.asp >> >> More worse is the acceptchanges in your code. >> It means that all the data in your dataset should be handled as been >> updated >> to the database. >> >> (You are not the first one who interprets this command wrong) >> :-) >> If means something as Accept changes as done. >> >> I hope this helps, >> >> Cor >> >> >> <mfleet1***@yahoo.ca> schreef in bericht >> news:1150746935.759541.103340@u72g2000cwu.googlegroups.com... >> > Hello. I'm fairly new to VB.Net (2003). I'm using a datagrid to >> > display data (access db) and when user double clicks on a record, >> > another form shows up which allows modification/addition of data. The >> > problem is when user accepts the changes made and gets back to >> > datagrid. The information displayed is still the old info. How do I >> > get the new information to display? Here is an example of the code >> > used to update the data: >> > >> > objDataSet.Tables("Table").Rows(objCurrencyManager.Position).BeginEdit() >> > objDataRow = >> > objDataSet.Tables("Table").Rows(objCurrencyManager.Position) >> > >> > With objDataRow >> > .Item("Field1") = Text1.Text >> > End With >> > objDataRow.AcceptChanges() >> > objDataSet.Tables("Table").Rows(objCurrencyManager.Position).AcceptChanges() >> > >> > Shouldn't the data in the datagrid diplay the information that was >> > entered in Text1.Text? Or is it that I'm doing something wrong? >> > >> > Many thanks for any replies!! >> > > Hey, now I think I see what you mean. I saw this mentioned in the book
"Programming Visual Basic.net" by Francesco Balena (first edition). He warned not to ever use the AcceptChanges command, becuase of what you are saying -- the "dataset" gets updated, but not the disk file. Thanks for your message. Cor Ligthert [MVP] wrote: Show quoteHide quote > Bob, > > I cannot answer yes or no on your question, because when you do the database > updates while editing it can be that you use it. But it has forever to do > with update from a database as long as you don't do that, you normally > should not use the acceptchanges. > > The acceptchanges can be used by instance in this sentence. > > myDataAdapter.Update(myDataTable.getchanges) > Not that this gives any advantage but let assume. > > The dataadapter marks the rowstate of rows which are done as not changed. > > But the myDataTable.getchanges is a copy of the datatable, so it has to be > done in the origanal as well. > > Therefore than the myDataTable.acceptchanges which means that those rows > will not be updated again. > > I hope that this makes it a little bit clear because there are not much > samples to give where it has to be used. It is not rare to use it, but there > are very few places (a cascade update by instance can need it as well). > > Cor > > > <b**@datasync.com> schreef in bericht > news:1150783832.084620.323740@c74g2000cwc.googlegroups.com... > > Cor, I am not clear on what you mean by saying "If means something as > > Accept changes as done." Does this mean you should AcceptChanges > > (update the database on disk) only when you are done and exit the > > DataGrid/program, and not during the editing process? Or, is it > > recommended to confirm/write/update a small portion of the data (ie, > > the row you just changed) right away? If the latter, how to you do > > that? > > > > Thanks. > > b**@datasync.com > > > > Cor Ligthert [MVP] wrote: > >> MFleet, > >> > >> I would try it by refreshing the datagrid. > >> > >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassrefreshtopic.asp > >> > >> More worse is the acceptchanges in your code. > >> It means that all the data in your dataset should be handled as been > >> updated > >> to the database. > >> > >> (You are not the first one who interprets this command wrong) > >> :-) > >> If means something as Accept changes as done. > >> > >> I hope this helps, > >> > >> Cor > >> > >> > >> <mfleet1***@yahoo.ca> schreef in bericht > >> news:1150746935.759541.103340@u72g2000cwu.googlegroups.com... > >> > Hello. I'm fairly new to VB.Net (2003). I'm using a datagrid to > >> > display data (access db) and when user double clicks on a record, > >> > another form shows up which allows modification/addition of data. The > >> > problem is when user accepts the changes made and gets back to > >> > datagrid. The information displayed is still the old info. How do I > >> > get the new information to display? Here is an example of the code > >> > used to update the data: > >> > > >> > objDataSet.Tables("Table").Rows(objCurrencyManager.Position).BeginEdit() > >> > objDataRow = > >> > objDataSet.Tables("Table").Rows(objCurrencyManager.Position) > >> > > >> > With objDataRow > >> > .Item("Field1") = Text1.Text > >> > End With > >> > objDataRow.AcceptChanges() > >> > objDataSet.Tables("Table").Rows(objCurrencyManager.Position).AcceptChanges() > >> > > >> > Shouldn't the data in the datagrid diplay the information that was > >> > entered in Text1.Text? Or is it that I'm doing something wrong? > >> > > >> > Many thanks for any replies!! > >> > > >
Oracle read only transaction in VB .NET?
Counting rows in an SQL table Locking a Combo-Box Security Exception when deploying a VB.NET 2003 solution. Concurrency question making a string var like "nr1 nr2 nr3" windows Registry parameter "any" VB 6 (what is your equivalent in vb 2005 ?) breaking information out of a string Importing Text File With Diacritical Marks |
|||||||||||||||||||||||