getting the primary key from a bindingsource save in c sharp

576 views Asked by At

I am using VS Express 2012 and SQL Express (localdb).

My question is in 2 parts but is based around the same function that I want.

1) in the save button of my bindingNavigator is the following code

this.Validate();
this.bsS24s.EndEdit();
this.tamS24s.UpdateAll(this.dsS24s);

I want to be able to interject another value into the datatable field that isn't bound to a form object. So from this form, field source_id should always = 1 (from another form it may be 2 etc.) How do I do that?

2) Once this row is saved (a new row), how do I get back the primary key? As I need to save some related data into another database table via a direct connection using SQL.

Many Thanks

0

There are 0 answers