winform中textBox控件的数据传到数据库,我们都知道用'"+txtBox.Text.Trim()+"'可以传值。但是,当textBox内容为空时,传值就会出错。对付这样的办法我们可以把txtBox的默认现在为null。也就是txtBox的Text设置为null。可这样,给客户的时候。客户说:这样看上去很不舒服。现在,要让txtBox什么都不显示,可在用'"+txtBox.Text.Trim()+"'传值的是自动传为null。怎么弄呀?请各位指点一二
调试欢乐多
{
......
}
{}不要给this.xxx.Text 赋值 null 会有不必要的麻烦
还有一种办法 sql 写的时候 where 子句 过滤一下 特殊情况
sb.Append("select j.dev_serial,u.user_lname,j.rec_datetime,j.user_serial from ")
.Append("jt_pass j,dq_user u where j.user_serial = u.user_serial ")
.Append("and j.jt_state is null and j.dev_serial = @EQUIPID");
command = new SqlCommand(sb.ToString(), sqlConn);
param = command.Parameters.Add("@EQUIPID", SqlDbType.Int);
param.Value = equipId;