Reputation: 1
here am trying to keep excel sheet data in to data set.help me to over from this error The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly. Dim ds As System.Data.DataSet Dim RecTab As Data.DataTable Dim RecTab1 As Data.DataTable Dim Rectab2 As Data.DataTable Dim ds1 As System.Data.DataSet Dim HFCell As String Dim HTCell As String Dim FilePath As String
HFCell = "A1"
HTCell = "B1"
m_FileName = "Data.xls"
FilePath = Server.MapPath("..\TankGauge\Data_Mgr") & "\" & m_FileName
Try
Dim connectionString As String = ""
Try
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + FilePath + ";" + "Extended Properties=Excel 8.0;"
MyConnection = New OleDbConnection(connectionString)
MyConnection.Open()
dataAdapter = New OleDbDataAdapter("SELECT * FROM [Sheet1$]", MyConnection)
ds = New Data.DataSet
dataAdapter.Fill(ds)
RecTab = ds.Tables(0)
MyConnection.Close()
Upvotes: 0
Views: 5244
Reputation: 91608
I believe the database driver you're using won't work. Try changing:
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + FilePath + ";" + "Extended Properties=Excel 8.0;"
to:
connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + FilePath + ";" + "Extended Properties=Excel 8.0;"
Upvotes: 0
Reputation: 1096
In your Excel workbook, is there a worksheet named Sheet1? If not, rename the sheet or change your code to call out the sheet you want to get data from.
Upvotes: 0