使用insertcommand.ExecuteOnQuery时出现语法错误(缺少运算符)

4urapxun  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(255)

我有一个excel电子表格,从中读取数据,并试图复制第二行并在表的末尾插入一个副本。为此,我尝试执行oledbdataadapter.insertcommand。以下是我对此的看法:

da = new OleDbDataAdapter("SELECT * FROM [" + tableName + "]", connection);
da.InsertCommand = new OleDbCommand();
da.InsertCommand.CommandText = "INSERT INTO [" + tableName + "] ([F1], [F2], [F3], [F4], [F5], [F6], [F7], [F8], [F9], [F10], [F11]) SELECT [F1], [F2], [F3], [F4], [F5], [F6], [F7], [F8], [F9], [F10], [11] FROM (SELECT (ROW_NUMBER() OVER(ORDER BY [F1]) AS RowNumber), * FROM [" + tableName + "]) AS CTE WHERE CTE.RowNumber = 2";
da.InsertCommand.Connection = connection;
da.InsertCommand.ExecuteNonQuery();

当它到达最后一行时,我得到一个错误 Syntax error (missing operator) in query expression 'ROW_NUMBER() OVER(ORDER BY [F1])'. 如何重写查询以避免发生此错误?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题