无法将参数值从 Guid 转换为字符串
我的知识已经结束了,也用谷歌搜索了答案,但没有运气:/
一周前一切都运行良好。
我在存储库上进行了恢复,重新创建了表适配器等......没有任何帮助。
当我尝试在应用程序中保存时,此时出现 SystemInvalidCastException:
PersonListDataSet.cs:
partial class P_GroupTableAdapter
{
public int Update(PersonListDataSet.P_GroupDataTable dataTable, string userId)
{
this.Adapter.InsertCommand.Parameters["@userId"].Value = userId;
this.Adapter.DeleteCommand.Parameters["@userId"].Value = userId;
this.Adapter.UpdateCommand.Parameters["@userId"].Value = userId;
return this.Update(dataTable); **<-- Exception occurs here**
}
}
Everything is 卡在这里,因为 Guid - 我使用放大镜工具检查了数据表预览,它确实是数据表列中的真正 Guid -无法转换为字符串???怎么会这样呢?
I am at the end of my knowledge and googled for the answer too but no luck :/
Week ago everything worked well.
I did a revert on the repository, recreated the tableadapter etc... nothing helped.
When I try to save in my application I get an SystemInvalidCastException at this point:
PersonListDataSet.cs:
partial class P_GroupTableAdapter
{
public int Update(PersonListDataSet.P_GroupDataTable dataTable, string userId)
{
this.Adapter.InsertCommand.Parameters["@userId"].Value = userId;
this.Adapter.DeleteCommand.Parameters["@userId"].Value = userId;
this.Adapter.UpdateCommand.Parameters["@userId"].Value = userId;
return this.Update(dataTable); **<-- Exception occurs here**
}
}
Everything is stuck here because a Guid - and I checked the datatable preview with the magnifier tool its really a true Guid in the column of the datatable - can not be converted to a string ??? How can that happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
恰恰相反。您的 userId 是一个字符串,您的参数需要一个 GUID 值:
提供的 UserId 是 GUID 支持的格式之一。构造函数支持多种格式。
根据下面的评论进行编辑:
事实证明,您是在询问如何运行这样的选择语句:
我认为您应该重新检查您的数据模型并找到解决方案。
It's the other way around. Your userId is a string and you need a GUID value for your parameters:
Provided UserId is in one of the supported formats for a GUID. The constructor supports many formats.
Edit, based on comments below:
It turns out that you are asking how to run a select statement like:
I think you should re-check your datamodel and find a solution.
您尝试过吗:
希望有帮助!
Have you tried:
Hope it helps!!!