By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,793 Members | 1,591 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,793 IT Pros & Developers. It's quick & easy.

Using GetChanges without DataAdapter

P: 6
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:

Dim UpdateVouchersCommand As New SqlCommand("spManageVouchers", Connection)
UpdateVouchersCommand.CommandType = CommandType.StoredProcedure
UpdateVouchersCommand.Parameters.AddWithValue("@or gcode", "orgcode")
UpdateVouchersInVouchingListCommand.ExecuteNonQuer y()

I then want to "refresh" the data in my dataset that this stored procedure updated:

DataTable = MyDataSet.Tables("MyTable").GetChanges()

I then use that DataTable to populate a ListView.

For me, using a stored procedure is easier for this particular function. But I'd be happy to hear feedback if this is a really bad way of doing this.

Apr 9 '07 #1
Share this Question
Share on Google+
1 Reply

P: 6
Apologies for responding to my own post. While I haven't really grasped why, I have come up with a work around and who knows this might be helpful to someone else.
Please feel free to correct me if the following information is incorrect.

The Command Builder which uses the DataAdapter to make changes requires a Primary Key in the select statement. In my situation, I was updating quite a few records and in which I could not use a Primary Key. However, I was not violating the PK or any constraints.

I therefore created an SqlCommand with a type of stored procedure. Using this process DataRowState.Modified turned up zero. DataRowState.Unchanged turned up my entire data table.

Therefore to refresh my data I:


I then executed the sub routine that added the data in the first place.

I would like to close by saying that I think the MS definition of GetChanges that i cited in my earlier post is misleading.
Apr 10 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.