sql = "select * from address where (name like = '%" + txtName.Text + "%' or '" + txtName.Text + "' = '' ) and (unit like = '%" + txtUnit.Text + "%' or '" + txtUnit.Text + "' = '' )"
解决方案 »
- 问一个关于static类型的问题。(唉,基础知识很重要啊)
- 一个小问题,可惜本人不会,请教,会的答一下!先答先得,呵
- c#注册时怎么写能去除特殊字符,只能是数字和字母?
- ==有谁用过Jmail吗?为什么pop3接收过来的邮件标题有的会出现乱码呢。==
- ie8.0下问题
- Uploadify-3.2在360浏览器中jquery.ui.dialog下点击选择文件没反应
- Default.aspx的问题
- 谁能给我一个写好的操作sql的C#类
- 如何让网页与数据库连接起来
- 两个页面之间如何传递中文参数
- 高分求 C#做的文件上传到WEB服务器下指定文件夹中源程序。(不够加分)
- 用户控件的状态维持问题,高手请进!
{
string sqlStr = "Select name,unit from address where name like '%" + txtName.Text + "%' and unit like '%" + txtUnit.Text + "%'";
}
else
{
string sqlStr = "Select name,unit from address where name like '%" + txtName.Text + "%' or unit like '%" + txtUnit.Text + "%'";
set @txtunit=txtUnit.text
select * from address where (name like '%' + @txtname + '%' and unit like +'%' + @txtunit+ '%'+ ) or (unit like +'%' + @txtunit+ '%'+ and @txtname = '' ) or (name like + '%' + @txtname+ '%'+ and @txtunit= '' )
你在数据库中没办法执行吧,因为你用了两个textbox了,库里没有:)
admire to death...
(
@Name varchar(50),
@Unit varchar(200)
)
as
select * from T_AddressList
where (([Name] like '@Name%' or [Name] is null) and (Unit like '@Unit%' or Unit is null))
GO