从字符串转换为 uniqueidentifier 时转换失败
我开始在 ASP.NET Gridview SQLDataSource 中收到此错误。一切都很好。在 Gridview 的编辑列中,我意外地添加了相同的列 (ID) 两次,但随后将其删除。我开始收到此错误。我不会在任何地方传递任何东西。这是一个连接两个表的简单选择语句。
SELECT T1.[ID], T1.[amg_id], T1.[FirstName], T1.[LastName],
T2.[UserName] FROM [T1] JOIN T2
on T1.ApplicationUserID = T2.UserID
我不知道我在哪里得到这个错误。然后我将 SQL 语句从 SQLDatasource 复制到 SQL Server Management Studio。令人惊讶的是我遇到了同样的错误。如果我拆分连接并单独提取记录,则两个查询都可以正常工作。不知道问题出在哪里以及它是如何开始的。同样的查询之前运行得很好。我希望一旦找到解决方案就可以回复这个问题。 SQL错误在这里:
Msg 8169, Level 16, State 2, Line 1 Conversion failed when converting from a character string to uniqueidentifier.
I started getting this error in ASP.NET Gridview SQLDataSource. Everything was fine. In the Edit Column, Gridview I accediently added the same colum (ID) twice but then I removed it. I started getting this error. I am not passing anything anywhere. It is a simple select statement which joins the two tables.
SELECT T1.[ID], T1.[amg_id], T1.[FirstName], T1.[LastName],
T2.[UserName] FROM [T1] JOIN T2
on T1.ApplicationUserID = T2.UserID
I could not figure how where I am getting this error. Then I copied my SQL statement from SQLDatasource to SQL Server Management Studio. Surprisingly I got the same error. If I split the join and pull the records individually, both queries work fine. Don't know where is the problem and how it got started. The same query ran fine before.I hope to reply to this question, once I find the solution. SQL Error is here:
Msg 8169, Level 16, State 2, Line 1 Conversion failed when converting from a character string to uniqueidentifier.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对这个问题只有一个想法 - T1.ApplicationUserID 和 T2.UserID 的类型不同......我认为这个闪存的出现是因为你提到的错误。请检查数据类型,它们是什么?
I have only one idea about this issue - the types of T1.ApplicationUserID and T2.UserID are different ... I think that this flash appears because of error you've mentioned. Please check the data types, what are they?