omegalove
asked on
DELETE statement conflicted with the REFERENCE constraint
Line: 976
Error: Sys.WebForms.PageRequestMa nagerServe rErrorExce ption: The DELETE statement conflicted with the REFERENCE constraint "FK_tbl_UserPMessage_tbl_P Message". The conflict occurred in database "omegalove", table "dbo.tbl_UserPMessage", column 'PMessageID'.
The statement has been terminated.
it does not like the below delete
string constr = ConfigurationManager.Conne ctionStrin gs["omegal oveConnect ionString" ].ToString ();
string query = "delete from tbl_PMessage " + "where PMessageID=@pmessageid";
Error: Sys.WebForms.PageRequestMa
The statement has been terminated.
it does not like the below delete
string constr = ConfigurationManager.Conne
string query = "delete from tbl_PMessage " + "where PMessageID=@pmessageid";
ALTER TABLE [dbo].[tbl_PMessage] WITH CHECK ADD CONSTRAINT [FK_PMessage_Profile] FOREIGN KEY([FromProfileID])
REFERENCES [dbo].[tbl_Profile] ([ProfileID])
GO
ALTER TABLE [dbo].[tbl_PMessage] CHECK CONSTRAINT [FK_PMessage_Profile]
GO
ALTER TABLE [dbo].[tbl_UserPMessage] WITH CHECK ADD CONSTRAINT [FK_UserPMessage_PMessage] FOREIGN KEY([PMessageID])
REFERENCES [dbo].[tbl_PMessage] ([PMessageID])
GO
ALTER TABLE [dbo].[tbl_UserPMessage] CHECK CONSTRAINT [FK_UserPMessage_PMessage]
GO
ALTER TABLE [dbo].[tbl_UserPMessage] WITH CHECK ADD CONSTRAINT [FK_UserPMessage_Profile] FOREIGN KEY([ProfileID])
REFERENCES [dbo].[tbl_Profile] ([ProfileID])
GO
ALTER TABLE [dbo].[tbl_UserPMessage] CHECK CONSTRAINT [FK_UserPMessage_Profile]
GO
-
9-7-2010-7-26-06-PM.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I see now how they did it
private void Inbox_ItemCommand(object source, System.Web.UI.WebControls. RepeaterCo mmandEvent Args e) {
if(e.CommandName == "delete") {
long nItemCount = 0;
foreach(RepeaterItem item in Inbox.Items)
{
if(((CheckBox)item.FindCon trol("Item Check")).C hecked)
{
DB.userpmessage_delete(((L abel)item. FindContro l("UserPMe ssageID")) .Text);
nItemCount++;
}
}
//TODO DB.pmessage_delete(e.Comma ndArgument );
BindData();
if(nItemCount==1)
AddLoadMessage(GetText("ms gdeleted1" ));
else
AddLoadMessage(String.Form at(GetText ("msgdelet ed2"),nIte mCount));
}
}
private void Inbox_ItemCommand(object source, System.Web.UI.WebControls.
if(e.CommandName == "delete") {
long nItemCount = 0;
foreach(RepeaterItem item in Inbox.Items)
{
if(((CheckBox)item.FindCon
{
DB.userpmessage_delete(((L
nItemCount++;
}
}
//TODO DB.pmessage_delete(e.Comma
BindData();
if(nItemCount==1)
AddLoadMessage(GetText("ms
else
AddLoadMessage(String.Form
}
}
ASKER
this is a one to many relationship
ASKER
string query = "delete tbl_UserPMessage where PMessageID=@pmessageid " + " delete tbl_PMessage where PMessageID=@pmessageid";
This would not do it? would it?
This would not do it? would it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
awesome work.
ASKER
how come they do not have to do this?
Open in new window