Connect to an excel using Oledb in an invoke code

Hello I am trying to create a database connection to an excel file and execute a query all in an invoke code . But i don’t know what to do at this point

Dim Conn As New OleDb.OleDbConnection
Dim dbsource As String
Dim dbProvider As String
Dim ExcelPropertise As String
Dim ExcelFullFilePath As String
Dim Query As String
dbProvider = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=”
ExcelPropertise = “;Extended Properties=”“Excel 12.0 Xml;HDR=YES”""
ExcelFullFilePath = in_TransactionItem
Conn.ConnectionString = dbProvider+ExcelFullFilePath+ExcelPropertise
Query= “Select * from [Sheet1$]”

Hi @David_Oku,
Could you describe it better? You wan to invoke this code right? What I see is that this code is only opening connection and selecting some data from sheet. But what about the data? You need to return them in variable or something if you want to use it.

Hello thank you @Pablito I am trying to read all contents of sheet 1 into a data table

But from what I see in the code you don’t have any variable where you returns your content to.

Thanks @Pablito , that’s exactly the help i needed :sweat_smile: i dont know what to do from there

Hmmm I’m not sure about it as invoking code to connect with DB might be hard and tricky. I know it’s not a solution but have you tried to search for similar cases on forum and web as well? I’m pretty sure there are many people who tried to achieve this through code.