简体   繁体   English

Microsoft Access 数据库引擎找不到对象“Sheet1$”

[英]The Microsoft Access database engine could not find the object 'Sheet1$

I am copying the template excel file saved in the server folder in to the same folder with different name.我正在将保存在服务器文件夹中的模板 excel 文件复制到具有不同名称的同一文件夹中。 to insert the value..I am able to copy the file but when I try to insert the values it shows sheet!$ could not found.插入值..我可以复制文件,但是当我尝试插入值时,它显示表!$ 找不到。 I have given correct sheet name..Only one sheet is added in the spread sheet named as sheet1.still it shows error .My code is given below.Nay idea about this error .I googled but asked me to check the folder and sheet name..it is correct only..please help me我给出了正确的工作表名称..在名为 sheet1 的电子表格中只添加了一张工作表。它仍然显示错误。我的代码在下面给出。关于这个错误的想法。我用谷歌搜索但让我检查文件夹和工作表名称..它只是正确的..请帮助我

        string xxx = "~/temp/" + "Tempfile" + dunsno + DateTime.Today.ToString("dd.MM.yyyy") + ".xlsx";
         DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath("~/temp/"));
                            var fileList = directoryInfo.GetFiles();
                            string newFileName = Server.MapPath("~/temp/" + "Tempfile" + dunsno + DateTime.Today.ToString("dd.MM.yyyy") + ".xlsx");
                            foreach (FileInfo fleInfo in fileList     

                       {
                                fleInfo.CopyTo(newFileName, true);
                       }
         string connStr = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=xxx;Extended Properties=""Excel 12.0 Xml;HDR=YES""");
         OleDbConnection MyConnection;
                            OleDbCommand MyCommand = new OleDbCommand();
                            MyConnection = new OleDbConnection(@connStr);

                            MyConnection.Open();
                            MyCommand.Connection = MyConnection;
                            string sql = "Insert into [Sheet1$] (id,name) values('3','c')";
                            MyCommand.CommandText = sql;
                            MyCommand.ExecuteNonQuery();
                            MyConnection.Close();

Replace:代替:

string connStr = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=xxx;Extended Properties=""Excel 12.0 Xml;HDR=YES""");

with

string connStr = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES""", newFileName);

如果您仍然收到如下错误“Microsoft Access 数据库引擎找不到对象...”,后跟您尝试从中读取数据的工作表名称,然后尝试 [工作表名称 $]。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft Jet数据库引擎找不到对象“ Sheet1 $ _” - The Microsoft Jet database engine could not find the object 'Sheet1$_' 尝试查询Excel文件时出现问题…“ Microsoft Office Access数据库引擎找不到对象'Sheet1 $'。” - Issue attempting to query an Excel file… “The Microsoft Office Access database engine could not find the object 'Sheet1$'..” GetColumnName()LinqToExcel for csv文件抛出错误Microsoft Jet数据库引擎找不到对象'Sheet1 $ .txt' - GetColumnName() LinqToExcel for csv file throw error The Microsoft Jet database engine could not find the object 'Sheet1$.txt' Microsoft Jet数据库引擎找不到对象“ ...” - The Microsoft Jet database engine could not find the object '…' Microsoft Jet数据库引擎找不到对象 - The Microsoft Jet database engine could not find the object Microsoft Jet数据库引擎找不到对象 - The Microsoft Jet database engine could not find the object Microsoft Office Access数据库引擎找不到对象“ PPR_Status_Detailed” - The Microsoft Office Access database engine could not find the object 'PPR_Status_Detailed' Microsoft jet 数据库引擎在读取 dbf 文件时找不到对象 - The Microsoft jet database engine could not find object while reading dbf file Microsoft Access 数据库引擎 2016 Redistributable 不起作用 - Microsoft Access Database Engine 2016 Redistributable is not working 添加“Microsoft Access数据库引擎2010可再发行组件”作为clickonce的先决条件 - add “Microsoft Access Database Engine 2010 Redistributable” as a prerequisite for clickonce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM