我需要能够在 c#.net 中将字符串转换为 hierarchyid - 我不能使用存储过程。
当我传入路径(字符串)时,查询失败,因为路径是这样存储的 '/' 而不是 /
我可以将其转换为另一种类型吗?
SqlCommand command = new SqlCommand("INSERT Structure (Path,Description,ParentID) " +
"VALUES(" + path + ".GetDescendant(" + lastChildPath +
", NULL) " +
",@description, @parentId", _connection);
——BitKFu
我已经添加了,这是它产生的 sql 查询:
CommandText = "INSERT Structure (Path,Description,ParentID) VALUES(CAST(/ AS hierarchyid).GetDescendant(NULL, NULL) ,@description, @parentId"
我收到以下错误:ex = {“'/' 附近的语法不正确。”}
--ck
这就是我所期待的
"INSERT Structure (Path,Description,ParentID) VALUES(/.GetDescendant(NULL, NULL) ,'Test', 1"
——保罗·鲁安
我已经看过这个页面,但它并没有真正帮助,除非我忽略了什么?
谢谢
克莱尔