OleDbCommand Stored Procedure Cannot Find Access Q

2019-08-04 13:47发布

问题:

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]


标签: c# oledb