OleDbCommand存储过程找不到访问查询 [英] OleDbCommand Stored Procedure Cannot Find Access Query

查看:116
本文介绍了OleDbCommand存储过程找不到访问查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OleDbCommand在C#中运行Access附加查询.

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
  1. AppendMe
  2. Append Me

AppendMe可以正常工作,但是当我尝试执行第二个Append Me时,我得到一个OleDbException找不到输入表或查询'Append'".换句话说,它只能看到字符串的第一个单词.我试过操纵字符串(使用逐字字符串等)
什么都行不通.
我正在使用c#Express 2010和Access 2003
这是代码的一部分

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();

推荐答案

如果SQL标识符包含有趣的字符(例如空格),则必须将其括在方括号中.

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

[Append Me]

这篇关于OleDbCommand存储过程找不到访问查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆