How to open excel 2016 workbook through OleDbConnection

  • Thread starter Thread starter anon1m0us
  • Start date Start date
A

anon1m0us

Guest
I need my program (vb.net) to open a protected excel sheet that is read only, query a value in a text box, and return the query into a message box.


I got it to work with OLEDBConnections, but it seems I cannot pass a password to excel using this method. Any suggestions?

Here is my code snippet in OLEDB

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 [Operating$] where ID LIKE " & txtID.Text & "", MyConnection)


Without a password, this works going into a datagridview. How would I get it into a message box?

Continue reading...
 
Back
Top