'Updating an Excel file with a database connection using vb.net
I use a OleDb-connection (oleExcelConnection) to read from an .xlsx-file (Data.xlsx) and save that information to a DataTable in order to process the data later.
I now have the problem that my data is stored online. So I created a local Data.xlsx-file which has a database connection and updates itself, when being opened. When using vb.net I am however not capable of updating my Data.xlsx so that the latest data is in it.
When using my 'oleExcelConnection' with this code:
sConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + XLSXPath + ";Extended Properties=""Excel 12.0;HDR=Yes;IMEX=1"""
oleExcelConnection = New OleDb.OleDbConnection(sConnection)
oleExcelConnection.Open()
I am not able to update in any circumstances my Data.xlsx-file, prior it is loaded. Is this correct or is there a way to update my Data.xlsx-file using 'oleExcelConnection'. My work-around would be to open the Data.xlsx, save it and then let 'oleExcelConnection' load it.
Is there are better way to update the locally stored .xlsx-file using vb.net?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
