PC Review


Reply
 
 
mfleet1973@yahoo.ca
Guest
Posts: n/a
 
      19th Jun 2006
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!!

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      20th Jun 2006
MFleet,

I would try it by refreshing the datagrid.

http://msdn.microsoft.com/library/de...freshtopic.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


<(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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!!
>



 
Reply With Quote
 
 
 
 
bob@datasync.com
Guest
Posts: n/a
 
      20th Jun 2006
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.
(E-Mail Removed)

Cor Ligthert [MVP] wrote:
> MFleet,
>
> I would try it by refreshing the datagrid.
>
> http://msdn.microsoft.com/library/de...freshtopic.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
>
>
> <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed)...
> > 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!!
> >


 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      20th Jun 2006
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


<(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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.
> (E-Mail Removed)
>
> Cor Ligthert [MVP] wrote:
>> MFleet,
>>
>> I would try it by refreshing the datagrid.
>>
>> http://msdn.microsoft.com/library/de...freshtopic.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
>>
>>
>> <(E-Mail Removed)> schreef in bericht
>> news:(E-Mail Removed)...
>> > 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!!
>> >

>



 
Reply With Quote
 
bob@datasync.com
Guest
Posts: n/a
 
      20th Jun 2006
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:
> 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
>
>
> <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed)...
> > 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.
> > (E-Mail Removed)
> >
> > Cor Ligthert [MVP] wrote:
> >> MFleet,
> >>
> >> I would try it by refreshing the datagrid.
> >>
> >> http://msdn.microsoft.com/library/de...freshtopic.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
> >>
> >>
> >> <(E-Mail Removed)> schreef in bericht
> >> news:(E-Mail Removed)...
> >> > 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!!
> >> >

> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Databinding Combobox to Master/Detail DataGrids Beth Massi [Architect MVP] Microsoft Dot NET Framework 2 14th Apr 2005 05:36 PM
HELP-Sorted Datagrids and modal dialogs =?Utf-8?B?aGVscA==?= Microsoft Dot NET Framework 2 10th May 2004 07:01 PM
Export multiple datagrids on web page to Excel Steve Chatham Microsoft Excel Programming 0 24th Feb 2004 08:23 PM
Two DataGrids on One Form? Could be simple solution, but I can't findcontrol !!! ssoss Microsoft ADO .NET 5 19th Sep 2003 04:21 PM
Navigating DataGrids: How to access information in Child Tables Gregory Persson Microsoft ADO .NET 1 14th Jul 2003 04:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:14 PM.