小编Ham*_*eez的帖子

如何使用oledb c#.net在excel中插入新行

我正在尽力在 excel 文件中插入一个新的数据行。请看一看。我正在使用 C#.net 框架 (3.5) 面临这个问题

代码:

try{
       string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\rising rent\\csharp-Excel.xls;Extended Properties='Excel 12.0;HDR=Yes;IMEX=1;MAXSCANROWS=15;READONLY=FALSE;ImportMixedTypes=Text'";
       OleDbConnection conn = new OleDbConnection(ConnectionString);
       conn.Open();
       OleDbCommand cmd = new OleDbCommand("INSERT INTO [Inventory$] (C_DATE) VALUES('555')",conn);
       cmd.ExecuteNonQuery();
       conn.Close();

}
catch (Exception ex)
{
       MessageBox.Show(ex.ToString());
}
Run Code Online (Sandbox Code Playgroud)

错误是这样的,请查看并分享您的观点

“System.Data.OleDb.OleDbException:操作必须使用可更新的查询。在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) 在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, System Object.executeResult) Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at RisingRentACar.Inventory.button1_Click(Object sender, EventArgs e) 在 C:\Users\Hamza Hafeez\Documents\Visual Studio 2015\Projects\RisingRentACar\RisingRentACar\Inventory.cs:line 82"

.net c# oledb excel

2
推荐指数
1
解决办法
8973
查看次数

如何使用PHP获取特定时区的当前时间

PHP中是否有任何方法或函数可以从Internet获取特定时区的当前DateTime.不是本地系统的时间.请指导我.

php codeigniter

0
推荐指数
1
解决办法
1507
查看次数

标签 统计

.net ×1

c# ×1

codeigniter ×1

excel ×1

oledb ×1

php ×1