简体   繁体   English

为什么抛出错误:指定的强制转换无效?

[英]Why throwing an error : specified cast is not valid?

I used 'userid' in sql is int datatype and in backend(.cs) also used same int data type then why throwing this error:'specified cast is not valid' 我在sql中使用的'userid'是int数据类型,而在backend(.cs)中也使用了相同的int数据类型,然后为什么抛出此错误:'specified cast is invalid'

var userRowsCustId = dsCustReg.Tables[0]
                              .AsEnumerable()
                              .Select(r => r.Field<int>("AccountNo"));

var allRowsCustId = dsAllTables.Tables[0]
                               .AsEnumerable()
                               .Select(r => r.Field<int>("UserId"));

IEnumerable<int> allIntersectingCustIds = userRowsCustId.Except(allRowsCustId);

if (allIntersectingCustIds.Any())
{
}

what is the solution for this error? 该错误的解决方案是什么?

error throwing at r => r.Field<int>("AccountNo") r => r.Field<int>("AccountNo")抛出错误

当我将其替换为double时,我接受了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM