In a C# 2010 application that I am working on, I want to use linq to sql to update 2 tables in a sql server 2008 database.
I want to do the following:
create new Table1 object ;
**Table 1 will contain the primary key.
create new Table2 object;
table2 will contain a foreign key column that refers to primary key in
Before and/or right after the submitchanges() event occurs, I would like to know what the value is for the primary key in table1 and the foreign key value is in table2. I would like to know what the table key value is so I can display this information on reports that will be generated right after the record(s) have been inserted into the database. Thus can you tell me how to determine what the primary key value is for table1 that also refers to the foreign key value in table 2?
using (TransactionScope ts = new TransactionScope())
int val1= tbl1.PrimaryKey;
int val2= tbl1.foreignKey;
if (strError == "")
ts.Complete(); // now both inserts are committed to the db
Last Visit: 31-Dec-99 19:00 Last Update: 29-May-15 15:45