string sqlstr = "select ID,NAME,AGE,JERQUEDATE,HOSPITAL,CLINIC,JC_DOCTOR,MACHINE,MIRRORIMAGE,DIAGNOSES,PATHOLOGY,SALARY from patientMsg where ";
if (this.DropHospital.SelectedItem.Text != "----请选择----")
{
sqlstr += " HOSPITAl='"+this.DropHospital.SelectedItem.Text+"'and";
}
if (this.DropClinic.SelectedItem.Text != "")
{
sqlstr += " CLINIC='" + this.DropClinic.SelectedItem.Text + "'and";
}
if (this.DropJcDoctor.SelectedItem.Text != "----请选择----")
{
sqlstr += " JC_DOCTOR ='" + this.DropJcDoctor.SelectedItem.Text + "'and";
}
if (this.DropSjDoctor.SelectedItem.Text != "----请选择----")
{
sqlstr += " SJ_DOCTOR ='" + this.DropSjDoctor.SelectedItem.Text + "'and";
}
if (this.DropMachine.SelectedItem.Text != "----请选择----")
{
sqlstr += " MACHINE ='" + this.DropMachine.SelectedItem.Text + "'and";
}
if (this.DropDate.SelectedItem.Text == "当天")
{
sqlstr += " JERQUEDATE ='" + DateTime.Today.ToShortDateString() + "' and";
}
//else if (this.DropDate.SelectedItem.Text == "本月")
{
sqlstr += " JERQUEDATE between '" + DateTime.Today.Year.ToString() + "-" + DateTime.Today.Month.ToString() + "-1" + "' and '" + DateTime.Today.ToShortDateString() + "' and";
}
//else if (this.DropDate.SelectedItem.Text == "本年")
{
sqlstr += " JERQUEDATE between '" + DateTime.Today.Year.ToString() + "-1-1" + "' and '" + DateTime.Today.ToShortDateString() + "' and";
}
//if (this.DropAge.SelectedItem.Text != "全部")
{
sqlstr += " AGE && '" + this.DropAge.SelectedItem.Text + "' && '" + this.txtAge.Text + "' and";
}
this.DropAge.SelectedItem.Text 里面是 > ,< , >= , <= ,=
怎么解决参数为空的问题 和 去掉最后一个 and
后面几句被屏掉的句子有点错误,大虾们也帮忙看看,谢谢了
[此贴子已经被作者于2007-7-24 17:18:01编辑过]