Tag: tsql sqldatasource

使用LIKE的SqlDataSource SelectCommand不起作用

我在SelectCommand有以下T-SQL: SELECT h.Business, hrl.frn FROM registration hrl INNER JOIN holder h on h.call = hrl.call WHERE (h.Business like ‘%’ + @business + ‘%’ and h.Business is not null) and (hrl.frn = @frn and hrl.frn is not null) business和frn绑定到控制参数,它应该返回数据,即使其中一个或两个都留空,但如果我只为frn输入数据,它不会返回任何内容。 我认为我的T-SQL做得不对,我也不确定我是否正确处理了like 。 如果两个文本框都留空,则应返回所有数据。 如果输入frn ,但是business留空,则只应返回与该frn相关的数据。 如果输入了business ,但是frn为空,则应返回所有匹配项, like business 。 如果两者都输入,则应返回仅与frn和business匹配的数据。 另外,我不确定是否真的需要做and is not null 。 protected […]