主题:初学者求助,哪位大侠有时间看看??
问题: 如果我要查当天的记录,应该怎么写??
下面是我写的代码:
//查询 PS:txtkhbh客户编号、txtbfsj拜访时间、txtbfr拜访人
string ls_sql,ls_where="";
if (this.txtkhbh.Text.Trim() != "" )
{
ls_where = " khbh like '" + this.txtkhbh.Text.Trim() + "%' ";
}
if (this.txtbfsj.Text.Trim() != "")
{
if (ls_where == "" )
{
ls_where = " bfsj >='"+this.txtbfsj.Text.Trim() + "' and bfsj < '"+ this.txtbfsj1.Text + "' ";
}
}
if(this.txtbfr.Text.Trim() != "")
{
if (ls_where == "")
{
ls_where = " bfr like '%"+this.txtbfr.Text.Trim() + "%'";
}
else
{
ls_where = ls_where + "and bfr like '%"+this.txtbfr.Text.Trim() +"%'";
}
}
if (ls_where == "")
{
ls_sql = "select * from bfkhb";
}
else
{
ls_sql = "select * from bfkhb where " + ls_where;
}
下面是我写的代码:
//查询 PS:txtkhbh客户编号、txtbfsj拜访时间、txtbfr拜访人
string ls_sql,ls_where="";
if (this.txtkhbh.Text.Trim() != "" )
{
ls_where = " khbh like '" + this.txtkhbh.Text.Trim() + "%' ";
}
if (this.txtbfsj.Text.Trim() != "")
{
if (ls_where == "" )
{
ls_where = " bfsj >='"+this.txtbfsj.Text.Trim() + "' and bfsj < '"+ this.txtbfsj1.Text + "' ";
}
}
if(this.txtbfr.Text.Trim() != "")
{
if (ls_where == "")
{
ls_where = " bfr like '%"+this.txtbfr.Text.Trim() + "%'";
}
else
{
ls_where = ls_where + "and bfr like '%"+this.txtbfr.Text.Trim() +"%'";
}
}
if (ls_where == "")
{
ls_sql = "select * from bfkhb";
}
else
{
ls_sql = "select * from bfkhb where " + ls_where;
}