Beginner's question about binding textboxes and adding records

G

Guest

I've created an extremly simple form for testing. I want to add records
using bound textboxes.

I've created a connection by dragging a SQLdataAdapter on to the form and
using the Wizard with no special conditions. (Just select * from a single
table.) I've bound a few textboxes to the fields (4 boxes and a
DateTimePicker to be exact). I fill the dataset on form load and I know I'm
getting data then.

My problem is this: Nothing I do will create a new row. I'm trying to add a
record with what I thought were the usual means.
Me.BindingContext(Me.DataSet31, "OrderH").EndCurrentEdit()
Me.BindingContext(Me.DataSet31, "OrderH").AddNew()

(The number of rows in the table does not increase and when I go to the
Update call there is no row with DataRowState = Added.)

What am I forgetting?
 
G

Guest

I'm afraid I'm still having problems with the basic concept.

I've created a form. The data adapter is setup such that the Select
statement has a parameter. This is intended to return one record or no
record. The form as a whole is intended to add or update a single record at
a time.

On load, if the form is in Add mode, I create a new instance of the dataset
(the defined dataset for that table, not a basic ds.) and call AddNew. Once
I have filled in the textboxes, I call EndCurrentEdit. This immediately
crashes. It always complains about 'Column <name> does not allow nulls' even
though I have filled in this particular column. (I have verified that this
textbox is bound to this particular field.)

Incidentally, the database table is designed such that none of the fields
permits nulls and every field has a default. (Shouldn't a default prevent
such errors?)
 

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