1
Answer

C# datacontext object

Photo of scampercat

scampercat

13y
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)

1
Photo of Sunny  Sharma
NA 18.4k 1m 11y
Have you tried resetting the IIS Server? If haven't yet, use "iisreset" command in cmd window with admin priviledge to reset the IIS server.


I did the same thing and it's working like a charm.


Hope it helps :)

Thanks.
0
Photo of Martin
NA 3 1.4k 11y
I realized after watching a (youtube) video that i had to install all components besides the extensions in the PHP Installation ...now it reponse :) and yes, also a iisreset was needed ...thanx!