Hi,
I will give you a suggestion ie,
instead of doing it from the front-end you can just write a stored procedure in your database and access that database.
This would reduce the complexity and also satisfies code minimization.
I can give you a example, you try it and you can reach me out for any queries.
I have developed a shopping cart application and i have the following tables:
1. Customers(Id, UserName, Password)
2. Address (Id, FirstName, LastName, EmailID, Country, State, City)
3.CustomerAddresses (CustomerId,AddressId)
all these tables are linked with each other (they have foreign key relation)
So, your proc should be sumthing like this:
CREATE PROC GenerateOrder
AS
BEGIN
DECLARE @CustomerId int,
@UserName nvarchar(100),
@Password nvarchar(100),
@FirstName nvarchar(100),
@LastName nvarchar(100),
@EmailID nvarchar(100),
@Country nvarchar(100),
@State nvarchar(100),
@City nvarchar(100),
@AddressId int
BEGIN
INSERT INTO Customer(UserName, Password) VALUES(@UserName,@Password)
SELECT @CustomerId = @@IDENTITY
INSERT INTO Address(FirstName,LastName,EmailID,Country,State,city)
VALUES(@FirstNAme,@LastName,@EmailID,@Country,@State,@City)
SELECT @AddressId = @@IDENTITY
INSERT INTO CustomerAddresses(CustomerId,AddressId)
VALUES(@CustomerId,@AddressId)
END
Mark as answer if satisfied........
Regards,
Shree M.
Kavya Shree Mandapalli
ramuvalmiki07-22001, if this helps please login to Mark As Answer. | Alert Moderator