1
Reply

C# datacontext object

Ask a question
scampercat

scampercat

12y
1.9k
1

 I have some questions about the C# asp.net code 2010 listed below that I want to add on to:

  1. The customer table that is updated by the code listed below has an identity key field called cust_id. For the next statment that needs to be executed, I need to know what the cust_id number is. Can you tell me what I need to do next to know what the cust_id number is?
  2. If I were to change the code listed below, I would need to update the customer table below. However, I would also need to add the cust_id in a second table called detail_table. The detail_table would use cust_id column as a foreign key column to the customer table. Can you tell me how to accomplish this task?

 protected void Customer_Detail(object sender, EventArgs e)
        {
            CustomersDataContext attDataContext = new CustomersDataContext();
            Customer att = null;
            att = new Customer();
            InsertCustomer(att);
            attDataContext.Customers.InsertOnSubmit(att);
            attDataContext.SubmitChanges();
        }
        protected void InsertCustomer(Customer att)
       {
            string a = txtReceiveDate.Text;
            att.Customer_Received_Date = Convert.ToDateTime(a);
            att.Discrepancy_Reports_Provided =ddlDisRpt.SelectedValue;
       } 


Answers (1)