Q

How do I get a data control to access information from an Excel spreadsheet?

How do I get a data control to access information from an Excel spreadsheet? I have tried the data form wizard

but my book is not clear enough. Take a look at the MS KB article titled "How-to: Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET."

Basically, it explains that you can use an OleDbConnection component to connect to the Excel workbook, using a connection string like the following:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Book1.xls;Extended
Properties="Excel 8.0;HDR=YES;"

The version of Excel depends on the workbook you're opening, and can be: "5.0" for Microsoft Excel 5.0 and 7.0 (95) and "8.0" for Microsoft Excel 8.0 (97), 9.0 (2000) and 10.0 (2002) workbooks. Once you have a connection to the workbook, you can use a DataAdapter and a Dataset just like against any database.

This was first published in February 2004

Dig deeper on .NET Framework database programming best practices

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close