Denaes Posted March 13, 2004 Posted March 13, 2004 I'm using Jet/Access (which shouldn't matter). I have a full page of textboxes and a listbox datasourced to an entire table in my dataset. When I choose to edit things, (unlock all of the listboxes) and update the database from the dataset, it informs me that the "Has Changes" property is set to false, even though I changed 5 fields and I can see it as I scroll through the dataset. When I choose new, it blanks all the fields and allows you to enter a new record. This sometimes registers a change. I even changed my Edit procedure to manually set each field equal to the textboxes and the "Has Changes" is still false. I'm going to take out the check for changes, as its not working, but still... thats an important check. You don't want to update a database if it has no changes. This is so puzzling. :confused: Quote
Roey Posted March 13, 2004 Posted March 13, 2004 Not too sure I understand you correctly. Are you using Databinding to these textboxes and then checking the bound dataset buy using GetChanges to find out if any changes have been made ? Quote
Denaes Posted March 13, 2004 Author Posted March 13, 2004 All of the controls are bound to a datatable (in the dataset). If I edit to change the values, they hold. They show up in the datatable as I scroll through it. In my UpdateDatabase procedure, I check to see if it has any changes like this: If Dataset.HasChanges then If Dataset.HasErrors then 'do stuff with errors Else 'Code to update database from dataset End If End If I'm using Debug.WriteLine to trace were the logic is going, and when I'm changing data in the dataset, it's not triggering the DataSet.HasChanges. It still shows false, even though I see changes in the dataset. Why is my changing the dataset not triggering the "HasChanges" to true? Is it only triggered when you add a new record or delete a record? Is there another way (other than databound controls) I should be doing the editing? Quote
Roey Posted March 13, 2004 Posted March 13, 2004 Are you using .EndCurrentEdit() prior to checking for changes Quote
Denaes Posted March 13, 2004 Author Posted March 13, 2004 Are you using .EndCurrentEdit() prior to checking for changes No. The document I read said that since it was databound to the controls, I didn't need to do anything. Is there anything I should do to begin/end an edit? I don't see a .EndCurrentEdit. Is it off the datatable or the dataset itself? I see .Add<TableName>Row, which creates a new row/record and .New<TableName>Row off of the DataTable. I don't see anything alluding to begining or ending an edit on either the DataSet or DataTable. Quote
*Experts* Nerseus Posted March 13, 2004 *Experts* Posted March 13, 2004 If you're not explicitly starting an "edit", you shouldn't have to end one. Maybe you're calling AcceptChanges at some point? That clears all the changes in the DataSet and should only be called after committing the changes. -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
Denaes Posted March 13, 2004 Author Posted March 13, 2004 I'm not using .AcceptChanges. The only thing I can think of is that I'm hiding 3 textboxes and Showing 3 corresponding Comboboxes. I'm hiding the textboxes to display State, CustomerStatus and CustomerType, and replacing them with a combobox databound to State, CustStatus and CustType DataTables respectivly. The Point is to show you what is in the record, but when you change it, you're limited to the choices the admin places in the table. Then I manually set those fields to be equal to the comboBoxes selected Text property. But I change the First and Last name, then save it. I check its value before I even try to save and "HasChanges" is false. Then I try to save it and "HasChanges" is false. Then I'm back in view mode. I have the changed text on the screen, I click next, then previous and the name is still there, so it must be in the dataset. This is pretty frustrating :D Quote
Denaes Posted March 15, 2004 Author Posted March 15, 2004 Problem fixed. I was altering the datatable itself. I switched to using a datarow and using the .BeginEdit and .EndEdit, which it looked like someone was alluding to. Thanks for the help :) Quote
jvcoach23 Posted March 15, 2004 Posted March 15, 2004 any chance you could post a little of the code... i'm so new to this stuff it would help me in the learning process Problem fixed. I was altering the datatable itself. I switched to using a datarow and using the .BeginEdit and .EndEdit, which it looked like someone was alluding to. Thanks for the help :) Quote JvCoach23 VB.Net newbie MS Sql Vet
Denaes Posted March 15, 2004 Author Posted March 15, 2004 any chance you could post a little of the code... i'm so new to this stuff it would help me in the learning process In case you missed it, I wrote up a 'lil tutorial, which I hope will help those learning all of this. I know I had a rough time with it :D http://www.xtremedotnettalk.com/showthread.php?p=410429#post410429 Quote
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.