System.invalidcastexception:指定的强制转换在VB.NET中无效 [英] System.invalidcastexception:specified cast is not valid in VB.NET

查看:130
本文介绍了System.invalidcastexception:指定的强制转换在VB.NET中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



由.Field(Of Integer)(columnname)引发的错误,请参考以下代码:

----- -------------------------------------------------- ----------------------



 DtSetBO =  New  System.Data.DataSet 
MyCommandBO.Fill(DtSetBO)
Dim BOTable As DataTable = DtSetBO.Tables( InvtDetailTbl

Dim query = From InvtDetailTbl In BOTable.AsEnumerable()
Where InvtDetailTbl.Field( Of String )( 产品线)<>
按InvtDetailTbl.Field排序( 字符串)( MES产品 )升序,
InvtDetailTbl.Field( 整数)( 收到日期时效)降序选择 InvtDetailTbl

Dim sortedInvt As DataTable = query.CopyToDataTable()
Dim 视图 As DataView = DataView(sortedInvt)
Dim sortedInvtQuery = from rowView As DataRowView In 视图
选择 rowView
DataGridView1.DataSource = sortedInvtQuery.ToList()





-------------------------------------------- --------------------------------



请指教什么应该对上述问题的正确陈述。



我尝试过:



尝试 CInt,.Field(of String),.Field(of double)

错误仍然存​​在。

解决方案

<big></big>InvtDetailTbl.Field(Of  DOUBLE )(收到日期老化)Descending Select InvtDetailTbl 


Hi,
Error thrown due to the .Field(Of Integer)("columnname"), please refer to the following code:
-----------------------------------------------------------------------------

DtSetBO = New System.Data.DataSet
MyCommandBO.Fill(DtSetBO)
Dim BOTable As DataTable = DtSetBO.Tables("InvtDetailTbl")

Dim query = From InvtDetailTbl In BOTable.AsEnumerable()
   Where InvtDetailTbl.Field(Of String)("Product Line") <> ""
  Order By InvtDetailTbl.Field(Of String)("MES Product") Ascending,
           InvtDetailTbl.Field(Of Integer)("Received Date Ageing") Descending Select InvtDetailTbl

Dim sortedInvt As DataTable = query.CopyToDataTable()
Dim view As DataView = New DataView(sortedInvt)
Dim sortedInvtQuery = From rowView As DataRowView In view
          Select rowView
DataGridView1.DataSource = sortedInvtQuery.ToList()



----------------------------------------------------------------------------

Please advise what should the correct statement for above issue.

What I have tried:

Tried on CInt, .Field(of String), .Field(of double).
Error persist.

解决方案

<big></big>InvtDetailTbl.Field(Of DOUBLE)("Received Date Ageing") Descending Select InvtDetailTbl


这篇关于System.invalidcastexception:指定的强制转换在VB.NET中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆