sql数据源问题

发布于 2024-08-02 12:46:03 字数 1483 浏览 7 评论 0原文

我有一个查询,当我在 sqlDataSource 控件(向导测试按钮)中测试它时,它可以工作,但当我运行页面时,它不起作用。我确保 gridview 有正确的 sqlDataSource 控件作为其源。这让我发疯。

其他人也发生过这种情况吗?

编辑:

它与where子句中的这一行有关(它是一个oracle数据库)

Where    (upper(AA.Email_Address)=UPPER(:Email_Address) OR :Email_Address IS NULL) AND 
 (upper(AA.Display_Name) Like  UPPER('%' || :Display_Name || '%')   OR :Display_Name IS NULL)

该页面单独与每个搜索子句一起使用,但当它们都在那里时则不起作用(它在带有两个参数的sqlDataSource向导测试中起作用,但当它们不存在时则不起作用)页面运行)

================================================ =========================================

编辑:

感谢您的查询建议看起来更干净。

我确实将默认的 CancelSelectOnNullParameter 属性设置为“true”。当我将其更改为 false 时,页面将不会显示。我收到此消息

“服务器应用程序不可用” 您尝试在此 Web 服务器上访问的 Web 应用程序当前不可用。请点击网络浏览器中的“刷新”按钮重试您的请求。 管理员注意:可以在 Web 服务器的应用程序事件日志中找到详细说明此特定请求失败原因的错误消息。请查看此日志条目以找出导致此错误发生的原因。 "

==================================

这是一个有效的查询,除非我运行页面

SELECT * 
FROM a Left Join b on b.institution_code=a.institution_code
WHERE 
      (upper(a.Login_Name)=UPPER('%' || :Login_Name || '%') OR :Login_Name IS NULL)
  AND (upper(a.Display_Name) Like  UPPER('%' || :Display_Name || '%')   OR :Display_Name IS NULL) 
  AND (upper(a.Email_Address)=UPPER(:Email_Address) OR :Email_Address IS NULL) 
  AND ((a.institution_code=:institution_code) OR :institution_code IS NULL)  
  AND (upper(b.institution_desc) Like  UPPER('%' || :institution_desc || '%')   OR :institution_desc IS NULL

I have a query that works when I test it in the sqlDataSource control (wizard test button) but it doesn't work when I run the page. I made sure the gridview has the correct sqlDataSource control as its source. This is driving me crazy.

Has this happened to anyone else?

edit:

It has something to do with this line in the where clause (it's an oracle database)

Where    (upper(AA.Email_Address)=UPPER(:Email_Address) OR :Email_Address IS NULL) AND 
 (upper(AA.Display_Name) Like  UPPER('%' || :Display_Name || '%')   OR :Display_Name IS NULL)

The page works with each of the search clauses individually but not when they are both there( it works in sqlDataSource wizard test with both paramters but not when the page runs)

=====================================================================================

Edit:

Thanks for the query advice that does look cleaner.

I did have the default CancelSelectOnNullParameter property set to "true". When I change it to false the page won't display. I get this message

"Server Application Unavailable
The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.
Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur. "

================================

Here is the query that works except when I run the page

SELECT * 
FROM a Left Join b on b.institution_code=a.institution_code
WHERE 
      (upper(a.Login_Name)=UPPER('%' || :Login_Name || '%') OR :Login_Name IS NULL)
  AND (upper(a.Display_Name) Like  UPPER('%' || :Display_Name || '%')   OR :Display_Name IS NULL) 
  AND (upper(a.Email_Address)=UPPER(:Email_Address) OR :Email_Address IS NULL) 
  AND ((a.institution_code=:institution_code) OR :institution_code IS NULL)  
  AND (upper(b.institution_desc) Like  UPPER('%' || :institution_desc || '%')   OR :institution_desc IS NULL

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遗心遗梦遗幸福 2024-08-09 12:46:03

您是否设置了数据源的正确 ProviderName 属性?

尝试

Provider="System.Data.OracleClient"

在 SqlDataSource 标记中设置属性。

Did you set correct ProviderName property of your datasource?

Try setting

Provider="System.Data.OracleClient"

attribute in your SqlDataSource tag.

陈甜 2024-08-09 12:46:03

首先,您可以更好地编写这样的查询,以从 where 子句中删除“OR”:

WHERE
        Upper(AA.Email_Address)  =  Upper(COALESCE(:Email_Address,AA.Email_Address))
    AND Upper(AA.Display_Name) LIKE Upper('%' || COALESCE(:Display_Name,AA.Display_Name) || '%')

至于您的具体问题,您可能会遇到 CancelSelectOnNullParameter 属性。只要将其设置为“false”就可以了。

First of all, you'll do better writing the query like this to remove the 'OR's from the where clause:

WHERE
        Upper(AA.Email_Address)  =  Upper(COALESCE(:Email_Address,AA.Email_Address))
    AND Upper(AA.Display_Name) LIKE Upper('%' || COALESCE(:Display_Name,AA.Display_Name) || '%')

As for your specific question, you're probably running into the CancelSelectOnNullParameter property. Just set it to "false" and you'll be fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文