这段是查询控件代码
protected void BtnSearch_Click(object sender, EventArgs e)
{
if (this.txtstart.Text==""&&this.txtwhither.Text=="")
{
this.Response.Write("不能为空!");
}
else
{
this.Response.Redirect(showmessage.aspx?UID=this.txtstart&DestD=this.txtwhither);
}
}
下面这段是查询结果显示代码:
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;
using System.Data;
public partial class showmessage : System.Web.UI.Page
{
SqlOperate sqloperate = new SqlOperate();
SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["constr"]);
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string sqlstr = "select * from tb_Wuliu";
this.dlDataBind(sqlstr, "tb_Wuliu", "id");
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
this.dlInfoBind();
}
protected void lnkbtnOne_Click(object sender, EventArgs e)
{
this.labPage.Text = "1";
this.dlInfoBind();
}
protected void lnkbtnUp_Click(object sender, EventArgs e)
{
this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text) - 1);
this.dlInfoBind();
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text) + 1);
this.dlInfoBind();
}
protected void lnkbtnBack_Click(object sender, EventArgs e)
{
this.labPage.Text = this.labBackPage.Text;
this.dlInfoBind();
}
public void dlDataBind(string sqlstr, string table, string dkf)
{
int curpage = Convert.ToInt32(this.labPage.Text);
PagedDataSource ps = new PagedDataSource();
sqlconn.Open();
SqlDataAdapter MyAdapter = new SqlDataAdapter(sqlstr, sqlconn);
DataSet ds = new DataSet();
MyAdapter.Fill(ds, table);
ps.DataSource = ds.Tables[table].DefaultView;
ps.AllowPaging = true; //是否可以分页
ps.PageSize = 5; //显示的数量
ps.CurrentPageIndex = curpage - 1; //取得当前页的页码
this.lnkbtnUp.Enabled = true;
this.lnkbtnNext.Enabled = true;
this.lnkbtnBack.Enabled = true;
this.lnkbtnOne.Enabled = true;
if (curpage == 1)
{
this.lnkbtnOne.Enabled = false;//不显示第一页按钮
this.lnkbtnUp.Enabled = false;//不显示上一页按钮
}
if (curpage == ps.PageCount)
{
this.lnkbtnNext.Enabled = false;//不显示下一页
this.lnkbtnBack.Enabled = false;//不显示最后一页
}
this.labBackPage.Text = Convert.ToString(ps.PageCount);
this.dlInfo.DataSource = ps;
this.dlInfo.DataKeyField = dkf;
this.dlInfo.DataBind();
}
public void dlInfoBind()
{
String sqlstr = "select * from tb_Wuliu where UID='" + this.Request["Price"].ToString() + "'and where='" + this.Request["CompanyName"].ToString() + "'and where='"+ this.Request["Linkman"].ToString() +"'and where='"+ this.Request["Tel"].ToString() +"'";
//this.SQLDataRead
}
}
帮我看看编程思想有没有出错?
谢谢!
这段是查询控件代码
protected void BtnSearch_Click(object sender, EventArgs e)
{
if (this.txtstart.Text==""&&this.txtwhither.Text=="")
{
this.Response.Write("不能为空!");
}
else
{
this.Response.Redirect(showmessage.aspx?UID=this.txtstart&DestD=this.txtwhither);
}
}
下面这段是查询结果显示代码:
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;
using System.Data;
public partial class showmessage : System.Web.UI.Page
{
SqlOperate sqloperate = new SqlOperate();
SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["constr"]);
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string sqlstr = "select * from tb_Wuliu";
this.dlDataBind(sqlstr, "tb_Wuliu", "id");
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
this.dlInfoBind();
}
protected void lnkbtnOne_Click(object sender, EventArgs e)
{
this.labPage.Text = "1";
this.dlInfoBind();
}
protected void lnkbtnUp_Click(object sender, EventArgs e)
{
this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text) - 1);
this.dlInfoBind();
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text) + 1);
this.dlInfoBind();
}
protected void lnkbtnBack_Click(object sender, EventArgs e)
{
this.labPage.Text = this.labBackPage.Text;
this.dlInfoBind();
}
public void dlDataBind(string sqlstr, string table, string dkf)
{
int curpage = Convert.ToInt32(this.labPage.Text);
PagedDataSource ps = new PagedDataSource();
sqlconn.Open();
SqlDataAdapter MyAdapter = new SqlDataAdapter(sqlstr, sqlconn);
DataSet ds = new DataSet();
MyAdapter.Fill(ds, table);
ps.DataSource = ds.Tables[table].DefaultView;
ps.AllowPaging = true; //是否可以分页
ps.PageSize = 5; //显示的数量
ps.CurrentPageIndex = curpage - 1; //取得当前页的页码
this.lnkbtnUp.Enabled = true;
this.lnkbtnNext.Enabled = true;
this.lnkbtnBack.Enabled = true;
this.lnkbtnOne.Enabled = true;
if (curpage == 1)
{
this.lnkbtnOne.Enabled = false;//不显示第一页按钮
this.lnkbtnUp.Enabled = false;//不显示上一页按钮
}
if (curpage == ps.PageCount)
{
this.lnkbtnNext.Enabled = false;//不显示下一页
this.lnkbtnBack.Enabled = false;//不显示最后一页
}
this.labBackPage.Text = Convert.ToString(ps.PageCount);
this.dlInfo.DataSource = ps;
this.dlInfo.DataKeyField = "dkf";
this.dlInfo.DataBind();
}
public void dlInfoBind()
{
String sqlstr = "select * from tb_Wuliu where UID='" + this.Request["Price"].ToString() + "'and where='" + this.Request["CompanyName"].ToString() + "'and where='"+ this.Request["Linkman"].ToString() +"'and where='"+ this.Request["Tel"].ToString() +"'";
//this.SQLDataRead
}
}
帮我看看编程思想有没有出错?
谢谢!
看看是不是这里的问题。
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]
这是为什么
哪位高手指点一下
谢谢!