Im struggling with getting tags to successfully add to the DB from a custom section I have setup. All the other fields work correctly and I can add and edit successfully.
My custom section has a form with 4 fields and the code to process the form looks this so far:
void save_Click(object sender, ImageClickEventArgs e)
{
string tag = txtTags.Text;
string group = "default";
int nodeId = int.Parse(Request["id"]);
int tagId = Tag.GetTagId(tag, group);
if (tagId == 0)
{
tagId = Tag.AddTag(tag, group);
}
Tag.AssociateTagToNode(nodeId, tagId);
string updateStatement =
@"update codeSnippets set
wrongWord = @wrongWord,
correctWord = @correctWord,
cause = @cause
where id = @id;";
umbraco.BusinessLogic.Application.SqlHelper.ExecuteNonQuery(
updateStatement,
umbraco.BusinessLogic.Application.SqlHelper.CreateParameter("@wrongword", txtWrongWord.Text),
umbraco.BusinessLogic.Application.SqlHelper.CreateParameter("@correctword", txtCorrectWord.Text),
umbraco.BusinessLogic.Application.SqlHelper.CreateParameter("@cause", txtCause.Text),
umbraco.BusinessLogic.Application.SqlHelper.CreateParameter("@id", nodeId)
);
}
The tag is adding to the cmstags table but I get an error when it tries to create therelationship to the node.
The error is:
Cannot add or update a child row: a foreign key constraint fails (`web211-database`.`cmstagrelationship`, CONSTRAINT `UMBRACONODE_CMSTAGRELATIONSHIP` FOREIGN KEY (`NODEID`) REFERENCES `umbraconode` (`ID`) ON DELETE CASCADE)
Can anyone give me any suggestiosn as to what is wrong or how to do this?
I think I have discovered the problem. The nodes that are being creating in my custom section are not being added to the NODEID list in the 'mstagrelationship' table. Therefore it fails as it cannot find the ID.
Custom Section Tags
Hi Everyone,
Im struggling with getting tags to successfully add to the DB from a custom section I have setup. All the other fields work correctly and I can add and edit successfully.
My custom section has a form with 4 fields and the code to process the form looks this so far:
The tag is adding to the cmstags table but I get an error when it tries to create therelationship to the node.
The error is:
Can anyone give me any suggestiosn as to what is wrong or how to do this?
Thanks
Robert
I think I have discovered the problem. The nodes that are being creating in my custom section are not being added to the NODEID list in the 'mstagrelationship' table. Therefore it fails as it cannot find the ID.
How do I get around this?
Thanks
Rob
Anyone? Need to figure out how I get my custom section nodes to appear in the cmstagrelationship.NODEID dropdown?
is working on a reply...