Imports System.Data Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim con As System.Data.OleDb.OleDbConnection Dim ds As System.Data.DataSet Dim cmd As System.Data.OleDb.OleDbDataAdapter Dim path As String path = "C:\\Users\\Bhargav Ginoya\\Documents\\Visual Studio 2010\\Projects\\Country Club india ltd\\Book1.xls" con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + "; Extended Properties=Excel 12.0;") cmd = New System.Data.OleDb.OleDbDataAdapter("Select * From[ALL MEMBERSHIP DETAIL$]", con) ds = New System.Data.DataSet cmd.Fill(ds) DataGridView1.DataSource = ds.Tables(0) con.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Try Dim MyConnection As System.Data.OleDb.OleDbConnection Dim DtSet As System.Data.DataSet Dim MyCommand As System.Data.OleDb.OleDbDataAdapter MyConnection = New System.Data.OleDb.OleDbConnection _ ("provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Bhargav Ginoya\\Documents\\Visual Studio 2010\\Projects\\Country Club india ltd\\Book1.xls; Extended Properties=Excel 12.0;") MyCommand = New System.Data.OleDb.OleDbDataAdapter _ ("select * from [ALL MEMBERSHIP DETAIL$]", MyConnection) MyCommand.TableMappings.Add("Table", "TestTable") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables(0) MyConnection.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)