Wednesday, December 4, 2013

Read Excel 2010 64 bit File on a 64 Bit Machine using OleDB Provider in VB.NET

Here's the VB.NET Version of this post Read Excel 2010 64 bit file using OleDB Provider in C#
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Option Strict On  
 Option Infer On  
 Imports System.Data  
 Public Class Form1  
   Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load  
     Dim MyConnection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='c:\\temp\\test.xlsx';Extended Properties=Excel 12.0;")  
     Dim DtSet As New DataSet()  
     Dim MyCommand As New OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)  
     Try  
       MyCommand.Fill(DtSet)  
       DataGridView1.DataSource = DtSet.Tables(0)  
       MyConnection.Close()  
     Catch ex As ApplicationException  
       Throw ex  
     Finally  
     End Try  
   End Sub  
 End Class  

0 comments:

Post a Comment