OleDbCommand Stored Procedure Cannot Find Access Query

坚强是说给别人听的谎言 提交于 2019-12-13 00:03:15

问题


I am attempting to run an Access append query in C# using OleDbCommand.

As a test I created two queries in the database (one a copy of the other)

  1. AppendMe
  2. Append Me

AppendMe works fine but when I attempt to execute the second Append Me I get an OleDbException "cannot find the input table or query 'Append'" In other words its only seeing the first word of the string. I've tried manipulating the string (using verbatim string etc)
Nothing works.
I am using c# Express 2010 and Access 2003
Here's an extract of the code

OleDbConnection conn = new OleDbConnection(connStr);
conn.Open();
string StdProc = "Append Me";
OleDbCommand cmd = new OleDbCommand(StdProc, conn);
cmd.CommandType = CommandType.StoredProcedure;
OleDbDataReader rdr = cmd.ExecuteReader();

回答1:


If an SQL indentifier contains funny characters, such as a space, it must be enclosed in square brackets.

[Append Me]


来源:https://stackoverflow.com/questions/6559190/oledbcommand-stored-procedure-cannot-find-access-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!