'vb.net excel to datatable

I have an excel file that has 3 sheets, I was able to read those sheets into 3 different variables as datatable. is there any way to run sql query on any datatable please check the last line (my invention code) here is my code:

  Dim table_customers As DataTable
    Dim table_materials As DataTable
    Dim table_movement As DataTable

    Dim MyConnection As System.Data.OleDb.OleDbConnection
    Dim DtSet As System.Data.DataSet
    Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
    MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Excel + ";Extended Properties=Excel 12.0;")
    MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [accounts$]", MyConnection)
    DtSet = New System.Data.DataSet
    MyCommand.Fill(DtSet)
    table_customers = DtSet.Tables(0)
    MyConnection.Close()
    MsgBox("customers ok")


    Dim sql = "select cusomer_name from  '" & table_customers & "' where condition inner join  '" & table_materials & "' on .....  "


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source