Best Method for Saving Data from a ASP.NET Web Form (not MVC) to Multiple Related SQL Server Tables
Posted on 2015-01-11
I'm learning, so please bear with me. This is a non-MVC project so please make the solutions relevant to ASP.NET 4.5.1 Website projects not using Entity Framework. (I'll get there one of these days but I'm not there yet.)
I've created an unbound web form that contains client data which needs to be saved in multiple related tables, starting with the client record. Once that is saved I need to use the client ID from the newly saved client record as the foreign key in the client address, telephone, and email records.
Step 1: Save client name.
Step 2: Get the Id (primary key) of the new client record.
Step 3: Save client address (using primary key from step 2 as foreign key in the address record).
Step 4: Save client phone number (using primary key from step 2 as foreign key in the phone record).
Step 5: Save client email address (using primary key from step 2 as foreign key in the email record).
I don't need to be told step by step how to do this (I think), but I do need to know the best way to get started with this.