Error: "Fill is not a member of OleDbCommand"

0

I'm in visual basic, trying to make a connection to a DB in access. To contextualize, the system is working with SQL, generating the connection data string, then the connection objects and their querys. The issue is that when trying to do the same, with access I get the header error, and that is when I send the data to the DataTable, they were using a .fill (). This is where he shows me the error. Error: "Fill is not a member of OleDbCommand"

The current code is as follows:

Connection String.

Public connection As String = "data source = MARLI_SRV; initial catalog = BD_Evasiones; user id = sa; password = xxxxxxxxxx"
Public access_connection As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=\C-186-PC\prueba\Evasiones 2017.accdb;"

Connection objects.

'Public Conexion As New SqlConnection(connection)
Public Conexion As New OleDbConnection(access_connection)

Select the database.

'Dim dr As New SqlDataAdapter("Select * From Evasiones Order by NroExpedicion", Conexion)
Dim dr As New OleDbCommand("Select * From Evasiones", Conexion)

Go to DataTable

 Dim dz As New DataTable
 dr.Fill(dz)
    
asked by Luippo 12.09.2017 в 14:21
source

1 answer

1

The error that shows you indicates that Fill does not belong to the OleDbCommand class.

To be able to make the Fill to a DataTable with OleDb you need to declare OleDbDataAdapter which is the class that contains the Fill:

'Declaramos el OleDbCommand '
Dim cmm As New OleDbCommand("Select * From Evasiones", Conexion)

'Declaramos el OleDbDataAdapter '
Dim dr As New OleDbDataAdapter(cmm)

'Hacemos el Fill al DataTable '
dr.Fill(dz)
    
answered by 12.09.2017 / 14:26
source