zoukankan      html  css  js  c++  java
  • 不能删除电子数据表的单元格

    使用OleDB方式操作Excel,删除Excel中的表时提示该错误。非常是奇怪(只是也是见怪不怪了,微软的东西就喜欢给出一些莫名其妙的错误提示),昨天还能删除的,今天就删除不了了(只是昨天到今天确实有个大动作。把系统Ghost到了SSD固态硬盘上了,但操作的Excel文件路径并没有改变)。

    具体错误信息:
    {System.Data.OleDb.OleDbException (0x80004005): 不能删除电子数据表的单元格。


    在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
    在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
    在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
    在 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
    在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
    在 System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
    在 Roadmap_Excel.Form1.button2_Click(Object sender, EventArgs e)

    相关代码:

    连接字符串:

    //定义OleDB连接字符串
                string strConn = "Provider=Microsoft.Ace.OleDb.12.0;Persist Security Info=False;" + "data source=" + @excelPath + ";Extended Properties='Excel 12.0; HDR=yes; IMEX=10'";
                OleDbConnection conn = new OleDbConnection();
                conn.ConnectionString = strConn;

    运行删除的代码:

                            try
                            {
                                cmd = new OleDbCommand("Drop Table [" + roadmapTableName + "]", conn);
                                cmd.ExecuteNonQuery();
                            }
                            catch (System.Exception ex)
                            {
                                textBox1.Text += ("删除数据表失败:" + ex.Message);
                                textBox1.Text += ("
    ");
                                //该 ISAM 不支持在链接表中删除数据。
                                cmd = new OleDbCommand("Delete From [" + roadmapTableName + "]", conn);
                                cmd.ExecuteNonQuery();
                            }

    实在找不到原因,那就手动删除吧。


    眼下还没找到解决的方法,网上也没搜索到相关问题的网页。

  • 相关阅读:
    收音机 德生
    Ubuntu14.04+安卓系统4.3+JDK6编译源码
    springboot2.0+redis实现消息队列+redis做缓存+mysql
    万能命令
    分享个强大的抓包工具
    Vue之Mustache语法
    Vue之vbind基本使用
    Centos7.3环境下安装最新版的Python3.8.4
    Vue之vonce、vhtml、vtext、vpre、vcloak的基本使用
    Centos7.3安装最新版本git
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/5259515.html
Copyright © 2011-2022 走看看