Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 11, 2012 01:57 PM by echotrain
Apr 09, 2012 08:30 PM|LINK
I have copied a development database to another instance on the same server for QA testing. The database name was changed from XXX_Dev to XXX_Test. The platform is SQL Server 2005. Inserting a new record produces this error:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Patient_AddressId". The conflict occurred in database "XXX_Test", table "dbo.XXX_Address", column "AddressId"
I first took this problem to the SQL Server forums on MSDN. I have traced the SQL in Profiler and it executes fine when I paste it into SSMS. I now believe the problem is in the Data Connection configuration of my DBML file, but I have been unable to adjust
the settings so that it is happy. I found some threads around that talk about programmatically setting the connection, but this application does not need that - I just want to set it once. I would be happy to hear any suggestions as to what I am missing.
Apr 11, 2012 03:16 AM|LINK
Apr 11, 2012 03:29 AM|LINK
Linq use the connection string in web.config.
You can try to change the connectionstring in your Web.config file to your test DB. And Rebuild the programe.
And I suggest you don't modify the DB name.
You can create a TestFolder and a Original Folder and copy the DB to this 2 folder, That's more safety.
hope it helpful.
Apr 11, 2012 01:57 PM|LINK
The problem has been identified, and was not in the DBML. There was a hard-coded reference to the database name in one of the stored procedures. See the detailed discussion at:
Thanks to SonicMan and Dino He for the suggestions on working with the connecton string.