各位高手帮忙呀!叩谢
各位高手帮忙呀!叩谢
很复杂的查询啊。可以用判断来做,下面我的代码不是asp的,但是你可以看一下是怎么实现的:
//设置查询语句
string strSql = "SELECT * FROM StudentInfo ";
//设置查询条件
string strSql1 = "";
//如果studentid(学号)输入框的内容不为空的话,
if (this.studentid.text!="")
{
//判断查询条件是否为空,如果为空的话,用where
if (strSql1.Length==0)
{
//加入查询条件
strSql1 = "WHERE (studentid = "+this.studentid.text+") ";
}
//如果不为空的话,用and
else
{
//加入查询条件
strSql1 += "and (studentid = "+this.studentid.text+") ";
}
}
//如果studentname(姓名)输入框的内容不为空的话,
if (this.studentname.text!="")
{
//判断查询条件是否为空,如果为空的话,用where
if (strSql1.Length==0)
{
//加入查询条件
strSql1 = "WHERE (studentname = "+this.studentname.text+") ";
}
//如果不为空的话,用and
else
{
//加入查询条件
strSql1 += "and (studentname = "+this.studentname.text+") ";
}
}
其它条件可以类似的判断,只是麻烦了一点
谢谢islet,yms123,volte,小笨笨的热心关注!小女子非常感激!
存储过程我没做过,具体不知道怎么实现,用islet说的方法,是不是还得再加上case语句,对选项进行判断,觉得很复杂,不知哪位高手能把思路和方法给我说的再详细点,不好意思,我是新手!
非常感谢大家的帮助!!