Cor,
Thanks for the reply. My example appears to have been lacking some
important information. Let me see if I can elaborate.
For ease, let's just consider a form that uses a DataSet that contains 2
tables named Customers and Contacts. The Contacts table can contain multiple
records for each Customer. On the form, I have a groupbox with information
about the customer and another groupbox with information about the last
contact created. The only buttons on the form are a New and Save button.
The New button creates a new customer (which in turn creates a new contact)
and the Save button saves the data. When the user clicks on the New button,
I do not know at that point whether they are going to enter a Contact or not,
so I call BindingContext(ds.Customers).AddNew() and
BindingContext(ds.Contacts).AddNew(). Assuming that the user entered data
for the customer, but not for the contact, when the user clicks Save, I need
a way to determine if information was entered for the contact section.
I know that I can loop through each field in ds.Contacts and determine if
any of them have values other than the defaults, but there has to be an
easier way.
If you have a better way of going about this, please let me know.
Again, thanks.
"Cor Ligthert [MVP]" wrote:
ASPNOT,
Have a look at this one.
http://www.vb-tips.com/default.aspx?...8-2e91e5295e7c
In the same way as in this sample at the delete in this sample you can of
course as well try the rejectchanges
http://msdn.microsoft.com/library/de...angestopic.asp
I hope this helps,
Cor
"Aspnot" <NO******************@nc.rr.com> schreef in bericht
news:62**********************************@microsof t.com... Background:
I have a data entry form that is bound to a DataSet. This DataSet
contains
9 tables and the form displays data from each table in textboxes, not a
DataGrid. One of the tables in the ParentTable and the rest are children.
For Example:
The form shows the Customer and their most recently added Contact (in
textboxes, not in a DataGrid). When I click the Add button on the form, I
enumerate through all of the DataTables in the DataSet and call
BindingContext(DataTable).AddNew(). (Now, make note that the end user may
not always decide to enter a contact's information.) (For this example,
assume that the user did not enter a contact.) When the user clicks on
Save,
I again enumerate through all of the DataTables in the DataSet and call
BindingContext(DataTable).EndCurrentEdit(). At this point every table in
the
DataSet shows as having 1 row. When really the row for the Contacts table
is
blank. This creates problems when trying to insert the data into the
database.
Is there a better way of doing this? I know that I could watch for entry
into any of the fields for the Contacts table and then call AddNew, but
that
would be cumbersome to code.
PS - I know that the best way to do this would be to have a button that
the
user clicks on to "Add New Contact" and then display a dialog form that
would
allow the end user to enter the nessary information, or even just enable
the
controls on the main form. That is the best and easiest way to accomplish
what I need to accomplish, however, my client wants it done the way
described
above. They are moving from a DOS-based DBase application and want this
to
act as much like the old app as possible.
Thanks in advance!!