473,708 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using GetChanges on a datatable

I have a datagrid which source is a dataset :

dgFields.Rows.D ataMember = m_dsFields.Tabl es(0).TableName
dgFields.Rows.D ataSource = m_dsFields

Now my values are displayed properly and when I add a row I call the
follwing :

Dim dtChanged As New DataTable
dtChanged = m_dsFields.Tabl es(0).GetChange s(DataRowState. Added)

but dtChanged is always equal to Nothing.

What am I doing wrong ?


Nov 21 '05 #1
24 5449

Can you show how you show us how you add the datarow, yesterday there was
somebody who thought he added it, however that was not done, there was alone
a new datarow created.

Nov 21 '05 #2
To be honnest I don't add anything. At the bottom of my datagrid there
is a new line so I fill in the txtboxes and that's it. I would assume
then that the changes made to the datagrid are reflected on to the
datasource, but I might be wrong.

The code above is all I do. What is missing ?

Nov 21 '05 #3
Actually it might be important that I mention that I've tried the exact
same code with the parameters DataRowState.Mo dified and
DatarowState.De leted, and that in both cases, my dtChanged is filled
with the right lines !!!!
Therefore I believe my code is correct, however something is wrong with
DatarowState.Ad ded or I'm missing something here !

Nov 21 '05 #4

You add probably a row using the datagrid.

Set this before your get changes than probably it will go.

BindingContext( m_dsFields.Tabl es(0)).EndCurre ntEdit
This pushes the changes from the datagrid into the dataset when there has
not been a rowchange.
I hope this helps,

Nov 21 '05 #5
I've done that:
Dim dtChanged As New DataTable
BindingContext( m_dsFields.Tabl es(0)).EndCurre ntEdit()
dtChanged = m_dsFields.Tabl es(0).GetChange s(DataRowState. Added)

But dtChanged is still Nothing :( I really don't understand why. That's
a pain !
What does BindingContext here ?

Nov 21 '05 #6
Actually I've noticed that it works with DataRowState.Mo dified. I mean
that even newly added rows are contained in dtChanged. I guess I can
use that if I can't get the Added method to work

Nov 21 '05 #7

Try this sample partially with your code, I had not any problem, it works
in my opinion as you and I would expect.
\\\needs a datagrid and a button on a form
Dim dt As New DataTable
Private Sub Form1_Load(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
dt.Columns.Add( "Place")
dt.Columns.Add( "Name")
dt.Columns.Add( "Key")
dt.LoadDataRow( New Object() {"Whatever", "Sam", "1"}, True)
dt.LoadDataRow( New Object() {"Whatelse", "Cor", "2"}, True)
DataGrid1.DataS ource = dt
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
Dim dtChanged As New DataTable
BindingContext( dt).EndCurrentE dit()
dtChanged = dt.GetChanges(D ataRowState.Add ed)
DataGrid1.DataS ource = Nothing
DataGrid1.DataS ource = dtChanged
End Sub
I hope this helps,

Nov 21 '05 #8
Thx Cor,
unfortunately it doesn't work for me. My dtChanged is still Nothing....
I'm giving up, I will use DataRowState.Mo dified instead...

Nov 21 '05 #9
unfortunately it doesn't work for me. My dtChanged is still Nothing....
I'm giving up, I will use DataRowState.Mo dified instead...

Did you try my sample, because it shows that dtChanged in the datagrid.

Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Paul | last post by:
I am writing a DataBase Client/Server pair of applications in C#. The client registers a query, the server populates a dataset and its contents sent via XML to be displayed in the client DataGrid. This works fine. When the data is modified in the client DataGrid, the DataGrid.GetChanges call populates the change dataset which is transferred back to the server and the DataAdapter is Updated. This is where I am having a couple of problems:...
by: Marty | last post by:
In winforms, I can bind a datagrid to a dataset. When the user wants to submit changes, it's easy to see what has changed with the DataSet "GetChanges" method. In ASP.Net, I can create the dataset, bind it to the grid, then send to the user. But upon postback, I have no way of knowing which items changed on the datagrid. Do I really have to roll my own code for this or is it possible to use the GetChanges method on the dataset after...
by: Sam | last post by:
Hi, Some people are going to say I drive them crazy again...but here we go... I have the following code : BindingContext(m_dsFields.Tables(0)).EndCurrentEdit() Dim dtModifiedData As DataTable = dsFields.Tables(0).GetChanges(DataRowState.Modified)
by: George | last post by:
Got a question about the side effect of DataAdapter.Update() and DataTable.GetChanges(). Say I set up a DataTable and a DataAdapter in a class. Delete (Not remove) a row in the data table and call the following method. public void JobListDataTableFromAccessCommitChange() { System.Data.DataTable oChangeDataTable;
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then can re-run the report and get fresh data. now, they would like to be able to compare the fresh data to the stored data, getting a break-down of added/deleted/changed rows. on the surface, this sounded plausible -- by deserializing the stored
by: daranee | last post by:
Documentation on GetChanges say the following: Gets a copy of the DataSet that contains all changes made to it since it was loaded or AcceptChanges was last called. Does this mean I can update via a stored procedure and getchanges will know, or do I need to do this update using a DataAdapter. Currently, I'm not getting any rows with GetChanges, but I'm a new programmer and it may be something entirely unrelated. I update my data like this:...
by: Matteo Migliore | last post by:
Hi. I writed a method that takes two DataTable with same schema and return a third DataTable that: - insert new rows from "compare" DataTable - delete rows contained in "source" and not in "compare" DataTable - update rows from "compare" -------------------------------------- public static DataTable GetMergedTable(DataTable source, DataTable compare)
by: LoanB | last post by:
Hey guys need some info here. I am adding, updating and deleting data on a datagrid. I pass the datagrid's datasource (datatable dt) to my data layer. Assuming I have already created and opened a connection in a business layer and passed it to my datalayer I am now stuck here: My business layer code is as follows: //UPDATE MATRIX STOCK DATA TO SQL DATABASE public void updateMatrixData(System.Data.DataTable dt)
by: John Sheppard | last post by:
Hello there, I have the following code; I do this as a work around for a dataset.haschanges method which doesnt appear to work correctly either For Each dt As DataTable In myDs.Tables If Not dt.GetChanges(DataRowState.Added) Is Nothing Then hasChanges=true If Not dt.GetChanges(DataRowState.Modified) Is Nothing Then hasChanges=true If Not dt.GetChanges(DataRowState.Deleted) Is Nothing Then
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.