从绑定控件执行存储过程时,“空或空全文谓词" [英] ‘Null or empty full-text predicate’ when executing a store procedure from a bound control

查看:46
本文介绍了从绑定控件执行存储过程时,“空或空全文谓词"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.Net应用程序中有一个页面,该页面用于通过存储过程搜索数据库.传递给存储的产品的参数之一通过ControlParameter绑定绑定到文本框.

I’ve got a page in my ASP.Net application that is used to search a database via a store procedure. One of the parameters passed to the stored produced is bound to a text box via a ControlParameter binding.

<asp:ControlParameter Name="EventDescription" Type="String" ControlID="ucTestLogSearch" PropertyName="EventDescription" />

文本将传递到SQL Server存储过程.存储过程定义了这样的参数:

The text is passed to a SQL Server stored procedure. The stored procedure defines the parameter like this:

@event_descrip VARCHAR(200) = NULL,

它在WHERE条件下使用该参数,如下所示:

And it uses the parameter in a WHERE condition like this:

(CONTAINS (le.event_descrip, @event_descrip) OR @event_descrip IS NULL)

我的问题是,如果文本框为空白,则会出现以下异常:空或空的全文谓词" .

My problem is that if the text box is blank, I get the following exception: ‘Null or empty full-text predicate’.

根据我的经验,在WHERE子句中检查是否为null应该足以防止此错误.

In my experience, having the check for null in the WHERE clause should be sufficient to prevent this error.

此外,在针对我的测试数据库服务器运行而不针对我的开发服务器运行时,出现异常.据我所知,服务器正在运行相同版本的SQL Server.唯一的区别是测试服务器是群集的,而开发服务器不是群集的.

In addition, I get the exception when running against my test DB server but not against my development server. As far as I can tell the server are running the same version of SQL Server. The only difference is that the test server is clustered and the development server is not.

任何人都可以解释为什么我会收到此错误,为什么在一台服务器上而不是另一台服务器上发生此错误,或者如何解决该错误?

Can anyone explain why I am getting this error, why it happens on one server and not another, or how I can work around it?

推荐答案

在选择查询之前声明以下语句:

Declare following statement before select query:

IF ISNULL(@event_descrip,'') = '' SET @event_descrip = '""'; 

这篇关于从绑定控件执行存储过程时,“空或空全文谓词"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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