I want to retrieve data from an excel sheet and display it in datagrid. I have the following code(not showing the declarations) :
con = New OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=c:\CAD.xls;Extended Properties=""Excel 8.0""")
cmd = New OleDb.OleDbCommand("Select * from [delete2$]", con)
dataset.Clear()
Try
adap.SelectCommand = cmd
adap.Fill(dataset, "[delete2$]")
dg.DataSource = dataset.Tables(0).DefaultView
Catch exp As Exception
MsgBox(exp.Message)
End Try
the program is neither giving any error nor displaying the contents of the excel sheet.Please guide me how to display the contents of the excel sheet(File name is CAD.xls and the sheet name is delete2).
con = New OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=c:\CAD.xls;Extended Properties=""Excel 8.0""")
cmd = New OleDb.OleDbCommand("Select * from [delete2$]", con)
dataset.Clear()
Try
adap.SelectCommand = cmd
adap.Fill(dataset, "[delete2$]")
dg.DataSource = dataset.Tables(0).DefaultView
Catch exp As Exception
MsgBox(exp.Message)
End Try
the program is neither giving any error nor displaying the contents of the excel sheet.Please guide me how to display the contents of the excel sheet(File name is CAD.xls and the sheet name is delete2).