Actually I think I've run into a problem see my data is related and I'm
getting an error... Insert statement conflicted with foreign key constraint.
Now I know why I'm getting the error and that is because I'm not making a
perfect copy.
See I'm inserting into a destination table that already has data so I can't
copy the CompanyID since it might already exist in the destination table so
the copy fails on the table "tblPeople".
tblCompany
--
CompanyID | Company | City | State
--
CREATE PROCEDURE tblCompanyInsert
(
@Company nvarchar(50),
@City nvarchar(50),
@State nvarchar(50)
)
AS
SET NOCOUNT OFF;
INSERT INTO dbo.tblCompany(Company, City, State) VALUES (@Company, @City,
@State);
SELECT ID, Company, City, State, FROM dbo.tblOLCompany WHERE (ID =
@@IDENTITY)
GO
tblPeople
--
ID | CompanyID | Name
--
CREATE PROCEDURE tblPeople
(
@CompanyID int,
@name nvarchar(50)
)
AS
SET NOCOUNT OFF;
INSERT INTO dbo.tblPeople(CompanyID, Name) VALUES (@CompanyID,
@name);
SELECT ID, CompanyID, Name FROM dbo.tblPeople WHERE (ID = @@IDENTITY)
GO
I know I'm close but I've just been looking at this too long and I'm going
cross-eyed
Any Ideas ????
--
Kate
William Ryan eMVP said:
You'll need to change the AcceptChangesDuringFill property to False on both
of the dataadapters. I have a walkthrough here
http://www.knowdotnet.com/articles/datasetmerge.html but that's all you'll
need to do. Then the rowstate will be inserted and as long as your insert
command is valid, you're good to go.
Let me know if you have any questions.
Bill