请问高手!在ASP.NET中,如何实现模糊查询啊?今天没分了!对不起大家!急啊! 我要实现一个简单的查询,在DropDownList中add一些值。怎么才能够实现以选中的值为参数,来查询数据库中相关的数据?并返回查询结果?用的是SQLSERVER数据库! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from temp where proname like '%" + searchkey + "%'";searchkey为变量. protected System.Web.UI.WebControls.Button btnClick; protected System.Web.UI.WebControls.DropDownList dropAuthors; private void Page_Load(object sender, System.EventArgs e) { if (! IsPostBack ) { SqlConnection conPubs; SqlCommand cmdSelect; SqlDataReader dtrAuthors; conPubs = new SqlConnection( @"Server=localhost;uid=sa;pwd=sa;Database=Pubs" ); conPubs.Open(); cmdSelect = new SqlCommand( "Select au_id, au_lname From Authors", conPubs ); dtrAuthors = cmdSelect.ExecuteReader(); dropAuthors.DataSource = dtrAuthors; dropAuthors.DataTextField = "au_lname"; // dropAuthors.DataValueField = "au_id"; dropAuthors.DataBind(); dtrAuthors.Close(); conPubs.Close(); } } private void btnClick_Click(object sender, System.EventArgs e) { Response.Write("作者的id为:" + dropAuthors.SelectedValue); Response.Write("<br>"); Response.Write("作者的姓名为:" + dropAuthors.SelectedItem.Text); } select * from table(你的表名) where aa(你的第一个列名) like '%"+this.DropList1.SelectedItem.Text+"%' or bb(你的第二个列名) like '%"+this.DropList1.SelectedItem.Text+"%' or ................ Asp.net,C#初学者进 百度搜索页面上的问题: |M| VS2005中自带的Web水晶报,如何用自定义的按钮来触发水晶报表中的打印按钮 求新闻采集器 asp.net 修改 word 【求助】想在自己做的网站根目录下附加一个论坛 asp.net上传文件问题 .net下各安裝目錄的內容 求助!panel和checkbox的脚本问题 <% @ Import Namespace="System.Data.ado" %> 出错,这是怎么回事 想问一下DataList怎么分页? ASP.NET如何读取Active Directory中的用户名和口令.
searchkey为变量.
protected System.Web.UI.WebControls.DropDownList dropAuthors;
private void Page_Load(object sender, System.EventArgs e)
{
if (! IsPostBack )
{
SqlConnection conPubs;
SqlCommand cmdSelect;
SqlDataReader dtrAuthors; conPubs = new SqlConnection( @"Server=localhost;uid=sa;pwd=sa;Database=Pubs" );
conPubs.Open();
cmdSelect = new SqlCommand( "Select au_id, au_lname From Authors", conPubs );
dtrAuthors = cmdSelect.ExecuteReader(); dropAuthors.DataSource = dtrAuthors;
dropAuthors.DataTextField = "au_lname";
// dropAuthors.DataValueField = "au_id";
dropAuthors.DataBind(); dtrAuthors.Close();
conPubs.Close();
}
} private void btnClick_Click(object sender, System.EventArgs e)
{
Response.Write("作者的id为:" + dropAuthors.SelectedValue);
Response.Write("<br>");
Response.Write("作者的姓名为:" + dropAuthors.SelectedItem.Text);
}