// 所以使用where 1=1 这样的语句,避免因无查询条件而带来的错误
objCommand.CommandText =" SELECT USERS.USERNAME, USERS.NICKNAME,USERS.USEREMAIL, USERROLE.ROLENAME " +" FROM USERS " + " LEFT JOIN USERROLE ON USERS.USERROLE = USERROLE.ROLELEVEL " +" WHERE 1=1 ";
if (tbxUserName.Text != "")
objCommand.CommandText += " AND USERS.USERNAME LIKE @USERNAME";
if (tbxNickName.Text != "")
文章来源于领测软件测试网 https://www.ltesting.net/