OleDb参数BUG或BAD DESIGN [英] OleDb Parameters BUG or BAD DESIGN

查看:58
本文介绍了OleDb参数BUG或BAD DESIGN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在执行SQL UPDATE查询,我注意到它们在

ExecuteNonQuery()调用中成功,没有异常引发但是它们失败了在

数据库。他们说他们在代码中取得了成功,但他们在数据库中失败了。


要解决这个问题,必须在他们所在的ORDER中调用Parameters.Add

SQL语句。


这是令人困惑和糟糕的。


如何重现。

构造一个SQL查询使用@ParamName ....来自

参数.Add(" @ ParamName",var);打电话。


谢谢。

Hi,

I was performing SQL UPDATE queries and I notice that they SUCCEED on the
ExecuteNonQuery() call with NO exceptions raised BUT they fail at the
Database. They say they succeed in the code but they fail at the database.

To fix this they Parameters.Add must be called in the ORDER they are in
the SQL STATEMENT.

This is confusing and bad.

How to repro.
Construct a SQL query with the @ParamName .... out of order from the
Parameter.Add("@ParamName", var); calls.

Thanks.

推荐答案



如果你使用OleDb而不是参数的标记可能是问题

标记(?)。

所以,以相同的顺序添加参数是唯一的OleDb的方式

认出他们。

或者你的情景有什么不同?


-

Miha Markic - RightHand .NET咨询&软件开发

miha at rthand com
www.rthand.com


< di ******** @ discussion.microsoft.com>在消息中写道

news:u8 ************** @ TK2MSFTNGP09.phx.gbl ...
Hi,

If you are using OleDb than markers for parameters are probably question
marks (?).
So, adding the parameters in the same order is the only way for OleDb to
recognize them.
Or is your scenario different?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

<di********@discussion.microsoft.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...

我正在执行SQL UPDATE查询,我注意到它们在
上成功执行了ExecuteNonQuery()调用,没有异常引发但是它们在
数据库中失败了。他们说他们在代码中取得了成功,但他们在数据库中失败了。

为了解决这个问题,他们必须在他们在SQL语句中的ORDER中调用Parameters.Add。

这是令人困惑和不好的。

如何重新编译。
使用@ParamName构造一个SQL查询....来自
Parameter.Add的乱序(@ ParamName,var);打电话。

谢谢。
Hi,

I was performing SQL UPDATE queries and I notice that they SUCCEED on the ExecuteNonQuery() call with NO exceptions raised BUT they fail at the
Database. They say they succeed in the code but they fail at the database.

To fix this they Parameters.Add must be called in the ORDER they are in
the SQL STATEMENT.

This is confusing and bad.

How to repro.
Construct a SQL query with the @ParamName .... out of order from the
Parameter.Add("@ParamName", var); calls.

Thanks.



我使用DatabaseCommand.Parameters.Add(" @ ParamName",paramVar) );


这就是它的记录方式以及它今天如何工作,问题是

ORDER oft Parameter.Add(方法调用必须匹配在SQL

语句中订购。


如果我们使用NAMED

PARAMATERS,则没有记录,也没有逻辑设计。


如果它依赖于订单,那么我们不需要命名参数。那个

是命名参数的整个概念。

我的书中有一个错误或不好的设计。

Miha Markic< miha at rthand com>写在留言中

news:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
I use DatabaseCommand.Parameters.Add("@ParamName", paramVar);

This is how it is documented and how it works today, the problem is the
ORDER oft he Parameter.Add( method calls MUST match the order in the SQL
statement.

This is NOT documented nor the logical design if we are using NAMED
PARAMATERS.

If it is dependant on the order we do NOT need named parameters then. That
is the entire concept of named parameters.

Its a bug or bad design in my book.
"Miha Markic" <miha at rthand com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...


如果你使用OleDb而不是标记对于参数可能是问题
标记(?)。
因此,以相同的顺序添加参数是唯一的OleDb认识他们的方式。
或者你的情景有什么不同?

- Miha Markic - RightHand .NET咨询&软件开发
miha at rthand com
www.rthand.com

< di ******** @ discussion.microsoft.com>在消息中写道
新闻:u8 ************** @ TK2MSFTNGP09.phx.gbl ...
Hi,

If you are using OleDb than markers for parameters are probably question
marks (?).
So, adding the parameters in the same order is the only way for OleDb to
recognize them.
Or is your scenario different?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

<di********@discussion.microsoft.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...

我正在执行SQL UPDATE查询,我注意到它们在
Hi,

I was performing SQL UPDATE queries and I notice that they SUCCEED on

上成功了

ExecuteNonQuery()调用,没有异常引发但是它们在
数据库中失败了。他们说他们在代码中取得了成功,但他们在
数据库中失败了。
为了解决这个问题,他们必须在ORDER中调用Parameters.Add,它们是SQL语句中的


这是令人困惑和不好的。

如何重新编译。
使用@ParamName构造一个SQL查询....来自
Parameter.Add的乱序(@ ParamName,var);打电话。

谢谢。
ExecuteNonQuery() call with NO exceptions raised BUT they fail at the
Database. They say they succeed in the code but they fail at the database.
To fix this they Parameters.Add must be called in the ORDER they are in the SQL STATEMENT.

This is confusing and bad.

How to repro.
Construct a SQL query with the @ParamName .... out of order from the
Parameter.Add("@ParamName", var); calls.

Thanks.




这里有2个问题。


1.它以编程方式成功执行ExecuteNonQuery(),实际上

它没有成功





2.命名参数如果不按顺序处理则不能正确处理

sql语句放置


Miha Markic < miha at rthand com>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
There are 2 issues here.

1. It programatically succeeds on the ExecuteNonQuery() call when in fact
it does NOT succeed

and

2. Named parameters are not processed correctly if they are not in order of
the sql statement placement


"Miha Markic" <miha at rthand com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...


如果使用OleDb而不是参数标记可能是问题
标记(?)。
因此,以相同的顺序添加参数是OleDb <的唯一方法认识他们。
或者你的情景有所不同吗?

- Miha Markic - RightHand .NET咨询&软件开发
miha at rthand com
www.rthand.com

< di ******** @ discussion.microsoft.com>在消息中写道
新闻:u8 ************** @ TK2MSFTNGP09.phx.gbl ...
Hi,

If you are using OleDb than markers for parameters are probably question
marks (?).
So, adding the parameters in the same order is the only way for OleDb to
recognize them.
Or is your scenario different?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

<di********@discussion.microsoft.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...

我正在执行SQL UPDATE查询,我注意到它们在
Hi,

I was performing SQL UPDATE queries and I notice that they SUCCEED on

上成功了

ExecuteNonQuery()调用,没有异常引发但是它们在
数据库中失败了。他们说他们在代码中取得了成功,但他们在
数据库中失败了。
为了解决这个问题,他们必须在ORDER中调用Parameters.Add,它们是SQL语句中的


这是令人困惑和不好的。

如何重新编译。
使用@ParamName构造一个SQL查询....来自
Parameter.Add的乱序(@ ParamName,var);打电话。

谢谢。
ExecuteNonQuery() call with NO exceptions raised BUT they fail at the
Database. They say they succeed in the code but they fail at the database.
To fix this they Parameters.Add must be called in the ORDER they are in the SQL STATEMENT.

This is confusing and bad.

How to repro.
Construct a SQL query with the @ParamName .... out of order from the
Parameter.Add("@ParamName", var); calls.

Thanks.




这篇关于OleDb参数BUG或BAD DESIGN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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