I have a parent table called Customers, customers has the primary key CustomerId, Foreign Key ContactId, CustomerName, Adress, and JobTitle.
The child table is called Contacts which has the primary key ContactId, ContactName, and Adress.
My Register Contact web GUI has textboxes with labels for the fields Name and Adress, seeing as I set the contact ID as identity it automatically increments.
When the fields are filled, I have a button that inserts the data into the DataBase. A second button provides the user with the option to transform the contact into a client transfering the previous info into the next form that is only missing the JobTitle info.
Transfering the the fields that the user types is easy enough using the following code.
Response.Redirect("FormularioContactos.aspx?Name=" + nom.Value);
if (Request.QueryString["Name"] != null)
nom.Value = Request.QueryString["Name"];
You can use SCOPE_IDENTITY() in sql insert statement to get the new ContactId value
INSERT INTO Contacts (ContactName, Adress) VALUES ('Name', 'Address') SELECT SCOPE_IDENTITY()