这是我对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表单。 注意: -
报告查看器查询需要:
何时所有where子句的字符串都为null,那么我的报表查看器为 应该选择查询是:
Query =“从Customer_New中选择Cust_Id,Card_Number,Clients_Title,Address_Current,Phone_Number,Mobile_Number”;
当任何两个where子句的字符串不匹配时 行数据库然后没有
将显示
答案 0 :(得分: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)