0

这是我对 wpf 表单的查询

Query = "select Cust_Id,Card_Number,Clients_Title,Address_Current,Phone_Number,Mobile_Number from Customer_New Where 1=1";
try
{
    if (txt_title.Text != "")
        Query += " and Clients_Title Like '%" + txt_title.Text + "%'";
    if (txt_address.Text != "")
        Query += " and Address_Current Like '%" + txt_address.Text + "%'";
    if (txt_phone.Text != "")
        Query += " and Phone_Number Like '%" + txt_phone.Text + "%'";
    if (txt_mobile.Text != "")
        Query += " and Mobile_Number Like '%" + txt_mobile.Text + "%'";
    if (cbo_location.Text != "")
        Query += " and AreaLocation Like '%" + cbo_location.Text + "%'";
}

catch { }

我想报告查看器查询数据,例如我的 wpf 表单。这是我在报表查看器中尝试的查询

SELECT        Cust_Id, Clients_Title, Card_Number, Key_Person, Address_Current, Phone_Number, Mobile_Number, AreaLocation
FROM            Customer_New
WHERE        (Clients_Title = @Clients_Title) OR
                         (Address_Current = @Address_Current) OR
                         (Phone_Number = @Phone_Number) OR
                         (Mobile_Number = @Mobile_Number) OR
                         (AreaLocation = @AreaLocation) 

谁能告诉我像 wpf form 这样的报表查看器查询。笔记 :-

  1. 我不能在报表查看器中使用不能使用 C# 控件。在报表查看器中我只能使用 sql
  2. 报表查看器查询需要的是:

    • 当 where 子句的所有字符串都为空时,我的报表查看器
      应该选择查询是:

      Query = "从 Customer_New 中选择 Cust_Id,Card_Number,Clients_Title,Address_Current,Phone_Number,Mobile_Number ";

    • 当 where 子句的任意两个字符串与对应的行 db 不匹配时,则什么都没有

    将显示

    • 最后,如果仅提供 where 子句的一个条件,将进行选择
4

1 回答 1

0
SELECT        Cust_Id, Clients_Title, Card_Number, Key_Person, Address_Current, Phone_Number, Mobile_Number, AreaLocation
FROM            Customer_New
    where        (CASE
        WHEN @Clients_Title != ''   THEN Clients_Title=@Clients_Title
      ELSE
         NULL IS NULL
      END)
      AND(CASE
        WHEN @Address_Current != '' THEN Address_Current =@Address_Current
      ELSE
         NULL IS NULL
      END)
              AND(CASE
        WHEN @Phone_Number != '' THEN Phone_Number=@Phone_Number
      ELSE
         NULL IS NULL
      END)
      AND(CASE
        WHEN @Mobile_Number != '' THEN Mobile_Number=@Mobile_Number
      ELSE
         NULL IS NULL
      END)
      AND(CASE
        WHEN @AreaLocation != '' THEN AreaLocation =@AreaLocation
      ELSE
         NULL IS NULL
      END) 
于 2013-11-19T16:05:36.713 回答