I am using stored procedure to insert data. I have 2 tables one to store the customer details and the other one is used to store the payment history. So when I press insert details button on my form this stored procedure is called. I have to insert data in both table at the same time.
[dbo].[CustomerDetails] has primary key CustomerId which is set to Auto Increment.
So at the time of insertion I want this CustomerId to Set as RecordId in [dbo].[PaymentHistory]
NOTE: All other information can be same, however each account is differentiated by primary key CustomerId in CustomerDetails
INSERT INTO [dbo].[CustomerDetails] ([CustomerName], [FatherName], [Cnic], [ContactNo], [Address], [City], [StartDate], [EndDate],[SamanDesc], [Tola], [Masha], [Rati], [Location], [Amount], [Percentage], [Months], [Days], [Status])
VALUES (@CustomerName, @FatherName, @Cnic, @ContactNo, @Address, @City, @StartDate, @EndDate, @SamanDesc, @Tola, @Masha, @Rati, @Location, @Amount, @Percentage, @Months, @Days, @Status);
INSERT INTO [dbo].[PaymentHistory] ([RecordId], [DatePaid], [Amount], [AmountPaid], [Profit])
VALUES (@id, @StartDate, @Amount, 0, 0);