Home > Enterprise >  BC50319 error using OleDb.OleDbDataAdapter.Fill
BC50319 error using OleDb.OleDbDataAdapter.Fill

Time:05-27

I get the error BC50319 on 'da.Fill(DataTableWorkstation)' which is part of this segment:

        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. As "solution" Microsoft tells me to change to Option Strict Off which I do want to avoid. Is there a another solution for this?

CodePudding user response:

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.

  • Related