Microsoft Jet 数据库引擎在 vb.net 中找不到对象“Sheet1$”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16819145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The Microsoft Jet database engine could not find the object 'Sheet1$' in vb.net
提问by Mounika Reddy
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
这里我试图将 Excel 工作表数据保留在数据集中。帮助我从这个错误中结束 Microsoft Jet 数据库引擎找不到对象“Sheet1$”。确保该对象存在并且您正确拼写了它的名称和路径名。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()
回答by fotijr
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.
在您的 Excel 工作簿中,是否有名为 Sheet1 的工作表?如果没有,请重命名工作表或更改代码以调出要从中获取数据的工作表。
回答by Mike Christensen
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;"

