注册 登录
编程论坛 ASP.NET技术论坛

查询问题(急)

bavfhpdn66 发布于 2007-05-07 20:22, 443 次点击

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
private void fillDg()
{
this.GridView1.DataSource = wayoperater.creatercon();
this.GridView1.DataBind();
}
protected void btnsearch_Click(object sender, EventArgs e)
{
string condition ="";
condition = "1=1";
if (this.ckbstart.Checked)
{
condition = "Start=" + this.txtstart.Text;

}
else
{
condition = "Start like '%'";
}
if (this.ckbwhither.Checked)
{
condition += " and Whither like '%" + this.txtwhither.Text + "%'";
}
DataView dv = new DataView(wayoperater.selectAlltb_Way());
dv.RowFilter =condition;
dv.Sort = "id Desc";
this.GridView1.DataSource = dv;
this.GridView1.DataBind();

}
}

为什么模糊查询可以
当我"kk"精确查询就提示“用户代码未处理 EvaluateException”错误!
未找到列[kk]

这是为什么
哪位高手指点一下
谢谢!

2 回复
#2
川流不息2007-05-07 20:37

if (this.ckbstart.Checked)
{
condition = "Start=" + this.txtstart.Text;

}

你這個字段是不是字符串?改為condition = "Start='" + this.txtstart.Text + "'";

#3
bavfhpdn662007-05-07 20:47

谢谢你!
可以拉

1