查看: 639|回复: 1
|
C#- 以Oledb sql 删除excel的指定数据
[复制链接]
|
|
想在不打开excel页面的情况下直接链接并且删除指定的数据,却出现以下error: Deleting data in a linked table is not supported by this ISAM.
private void btn_Delete_Click(object sender, EventArgs e)
{
string ConnectionString = null;
OleDbConnection con2 = new OleDbConnection(ConnectionString);
con2.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\DataBase\GeneralData ;Extended Properties=Excel 12.0 XML;";
string sql = "DELETE FROM [InspectorList$] WHERE InspectorList ='" + cmb_Inspector.Text + "'";
OleDbCommand Deletecmd = new OleDbCommand(sql, con2);
con2.Open();
Deletecmd.ExecuteNonQuery();
con2.Close();
}
|
|
|
|
|
|
|
|
发表于 28-12-2017 08:47 PM
来自手机
|
显示全部楼层
有尝试 excel save as 2003 来测试吗?
connection string 需要修改。
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|