使用我在网络上找到的示例我创建了一个使用GetReparentedValue来修正儿童的函数。无法在对象中插入重复键(GetReparentedValue/hierarchyid)
但是,当我运行代码时出现以下错误:无法在对象中插入重复键。
我明白为什么(因为我试图重新抚养孩子,而且新父母已经有孩子,所以我需要知道新父母结构中孩子的MAX路径(hierarchyid),但我不明白实际上,我打算这样做。
路径将0x58
oldPath 0X
新路径0x68
SqlCommand command = new SqlCommand("UPDATE Structure SET " +
"Path = " + path + ".GetReparentedValue" +
"(" +
oldPath + ", " + newPath +
")" +
"ParentID = @id " +
"WHERE Path = " + path, _connection);
我要为此添加一个孩子的时候,所以我认为这将需要在某个地方,添加到上面的查询,但我不知道在哪里path + ".GetDescendant(" + lastChildPath + ", NULL)
数据库表
StructureID int Unchecked
Path hierarchyid Unchecked
PathLevel ([Path].[GetLevel]()) Checked
Description nvarchar(50) Checked
ParentID int Checked
ParentPath ([Path].[GetAncestor]((1))) Checked
任何人有什么建议吗?
在此先感谢您的帮助:-)
克莱尔
你能展示你的餐桌是什么样的吗? – 2010-08-25 18:03:51
罗纳德你好,我添加了表格 – ClareBear 2010-08-26 07:12:17