INSERT INTO语句包含以下未知字段名称:'a'.确保您正确输入了名称,然后重试该操作 [英] The INSERT INTO statement contains the following unknown field name: 'a'. Make sure you have typed the name correctly, and try the operation again
本文介绍了INSERT INTO语句包含以下未知字段名称:'a'.确保您正确输入了名称,然后重试该操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
//e,g,我想在第一行插入3列,在其余行插入10列 //我正在创建工作表名称为MySheet的excel文件 //然后更新第一行中的值,标题的第一单元格为空白 //然后插入数据 //任何人都可以帮助在没有标题的excel中插入数据
// e,g, I want to insert 3 columns in 1st row and 10 columns in rest of the rows //I am Creating excel file with sheet name as MySheet // then updating value in 1st row, 1st cell of header as blank //then inserting data // Can anyone please help to insert data in excel without header
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName +
";Mode=ReadWrite;Extended Properties=\"Excel 12.0 XML;HDR=NO\"";
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
conn.Open();
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = conn;
cmd.CommandText = "CREATE TABLE [MySheet] (a string)";
cmd.ExecuteNonQuery();
cmd.CommandText = "UPDATE [MySheet$] SET F1 = \"\"";
cmd.ExecuteNonQuery();
cmd.CommandText = "INSERT INTO [MySheet] (a) values ('ABC')" //<-----Getting error to insert
cmd.ExecuteNonQuery();
}
}
conn.Close();
推荐答案
只需尝试[删除(a)]
Just try [removed the (a)]
cmd.CommandText = "INSERT INTO [MySheet] values ('ABC')";
这篇关于INSERT INTO语句包含以下未知字段名称:'a'.确保您正确输入了名称,然后重试该操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文