Adding New Record - SQL Expres DB

M

Miro

vb.net 2005 express

I havnt posted in a while but I have been busy doing the tutorials on the
SQL Express and the first VB.net videos.
( Basically started from scratch and gave up the idea of mdb tables and
moving to SQL Express ).

One thing I cant seem to find / figure out is this.

I have dragged a table onto my form which in term binded everything for me
and also put a navigator.
Lets say this table has
ID ( unique key ) - Auto Increment
Name varchar(20) - not nullable


Then I added the Name field to the form as well ( so its binded as well).

As i click on teh add buttons on the binding navigator, the field i added
also updates.
If I click on the add button within the binding navigator, the field in the
datagrid jumps to the bottom with a
new 'ID' that has been autoincremented and the Name field is blank awaiting
input.

I can now either edit the field in the datagrid or the field.
Once I do this - i click save and all is well.

How do I 'code' the add button manually in a command button.
I cant seem to figure out how to look at the binding navigators code.
-so everything "blanks" on the textboxes, the navigator goes to the
bottom and ready for input.

Thanks

Miro
 
M

Miro

I got it,

Very simple, once you can get through the help files no express

Me.BindingSourceName.AddNew()

This throws the datagrid into an add mode and at the same time clears all
your binded text boxes.

and to save,
Me.Me.BindingSourceName.AddNew.EndEdit()
Me.TableAdapterName.Update(Me.DataSetName.TableName)

Cheers'

Miro
 

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