Add record in bound form

G

Guest

Hi

In .NET I created a form with bound controls (Access Database). I used a dataset and followed examples to create a navigation using the Binding Context. So far everything goes well
My question, how do I add a new record to the database AFTER the user filled in the fields on the form. When the user presses a buttonNEW all controls (bound) need to be empty on the form so the user can fill in the fields. When the user presses the buttonSAVE the record needs to be saved. The problem is that my database has some fields that are required before I can add the row to the database. I can't find a solution anywhere.

Do you know how to do this. How to display a new row in a form with bound controls.

Thx in advance!
Mauric
 
W

William Ryan eMVP

Maurice:
Maurice said:
Hi,

In .NET I created a form with bound controls (Access Database). I used a
dataset and followed examples to create a navigation using the Binding
Context. So far everything goes well.
My question, how do I add a new record to the database AFTER the user
filled in the fields on the form. When the user presses a buttonNEW all
controls (bound) need to be empty on the form so the user can fill in the
fields. When the user presses the buttonSAVE the record needs to be saved.
The problem is that my database has some fields that are required before I
can add the row to the database. I can't find a solution anywhere.
Do you know how to do this. How to display a new row in a form with bound controls..

Thx in advance!!
Maurice

Since you're using a BindingContext, you can all the .AddNew Method to add
a new row and effectively clear what's there. Now, you may want to consider
adding Default values to your respective DataColumns once you have your
dataset filled. When you add a new record, those values will populate
themselves, so its a must that everythign is blank, this won't do it for
you. however, once you hit the Save button, you can check the values of the
row and if they aren't there and are required, you can programatically add
them.

If you could tell me a little more about the overall scenario, I could be of
more help. For instance, are you only doing simple binding or are you using
Grid/ListBox/Combobox? Do you have any datarelations defined? what
specifically is the problem you have now, that you can't add a new row or
that it won't save on update?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top