C#OleDBConnection Excel
|
继此问题之后C#OLEDB与Excel的连接
我在使用OLEdbCommandBuilder时遇到问题。
我有以下代码:
DataTable dt = new DataTable();
OleDbCommand command = new OleDbCommand();
command = new OleDbCommand(\"Select * from [working sheet$]\", oleDBConnection);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
dataAdapter.SelectCommand = command;
OleDbCommandBuilder c = new OleDbCommandBuilder(dataAdapter);
dataAdapter.Fill(dt);
//arbitrary changed datatable
dt.Rows[2][3] = \"dfd\";
c.GetUpdateCommand();
dataAdapter.Update(dt);
oleDBConnection.Close();
但是,当我运行它时,出现此错误:
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
如何使用更新的行/单元格信息更新Excel工作表?我以前从未用过这种方式来处理Excel。
我已经搜索了错误,但找不到符合我确切要求的任何内容。
谢谢,
达伦
没有找到相关结果
已邀请:
1 个回复
死簇