简体   繁体   English

BC50319 错误使用 OleDb.OleDbDataAdapter.Fill

[英]BC50319 error using OleDb.OleDbDataAdapter.Fill

I get the error BC50319 on 'da.Fill(DataTableWorkstation)' which is part of this segment:我在“da.Fill(DataTableWorkstation)”上收到错误BC50319 ,这是该段的一部分:

        Using da As New OleDb.OleDbDataAdapter(oleExcelCommand)
            DataTableWorkstation = New System.Data.DataTable
            da.Fill(DataTableWorkstation)
        End Using

In that line I am opening a .xlsx-file containing data (strings, numbers and dates) and save this data to a DataTable .在该行中,我打开一个包含数据(字符串、数字和日期)的 .xlsx 文件,并将这些数据保存到DataTable As "solution" Microsoft tells me to change to Option Strict Off which I do want to avoid.作为“解决方案”,Microsoft 告诉我更改为Option Strict Off ,我确实想避免这种情况。 Is there a another solution for this?有另一种解决方案吗?

The solution for the problem is, that I need to be explicit when initializing variables.该问题的解决方案是,在初始化变量时我需要明确。 I had to change the initialization of my variable from this:我不得不改变我的变量的初始化:

Dim DataTableWorkstation As DataTable

to this:对此:

Dim DataTableWorkstation As System.Data.DataTable

and the error is gone.并且错误消失了。

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

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