- Open Visual Studio 2005, and bring up the "Server Explorer" (View > Server Explorer)
- Next, click the icon to "Connect to Database"
- Choose "Microsoft Access Database File" as your data source
- We choose this because we want the .NET OLE DB Data Provider
- Click "OK" to get to the "Add Connection" dialog
- Browse to your Excel file
- You'll need to change your "Files of type" from "*.mdb" to "*.*"
- Next click the "Advanced..." button in the "Add Connection" dialog
- Locate "Advanced > Extended Properties"
- Paste in "Excel 8.0;HDR=Yes;IMEX=1"
According to www.ConnectionStrings.com:"HDR=Yes;" indicates that the first row contains column names, not data. "HDR=No;" indicates the opposite.
"IMEX=1;" tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative.
- Click "OK" for the "Advanced Properties" dialog
- Click “Test Connection” to verify if you have everything set up correctly.
- Click "OK" for the "Add Connection" dialog
- You're all set, your Excel file should now appear in your database list.
Monday, October 22, 2007
Treat an Excel Workbook like a database with Visual Studio
I've been doing a lot of work with MS Excel 2003 lately. Specifically, I'm using it as a data source for an application. I recently learned Visual Studio 2005 can connect to an Excel workbook and treat it like a database.
I thought I would share my findings.
Here's how it's done:
Subscribe to:
Post Comments (Atom)
Cool Man...
ReplyDeleteLearnt a new thing, dude.
Thanks a million
Nice job
ReplyDeleteJustin,
ReplyDeleteI have tried that but that does not seem to work for me, I keep on getting the following error message:
Cannot find the installable ISAM
Eric
Could not find installable ISAM
ReplyDeleteWhat to do sir
Thank you for some different informative blog. Wherein else may want to I am getting that kind of facts written in such an ideal approach? I have a challenge that I’m simply now operating on, and i have been on the appearance out for such records. https://view.ly/v/W7bQdazBruOw
ReplyDelete