如何将.aspx页面中TextBox的值传入.cs文件的sql语句中?下面给出cs文件代码。
usingSystem;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingSystem.W...
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ImgBtn_Click(object sender, ImageClickEventArgs e)
{
string StrConn = ConfigurationManager.ConnectionStrings["JYGConnStr"].ConnectionString;
SqlConnection MyConn = new SqlConnection(StrConn);
MyConn.Open();
if (Request.Form["Keyword"] != null)
{
Keyword.Text = Server.HtmlDecode(Request.Form["Keyword"].ToString());
}
string SQLstring = "SELECT [LandUser], [LangStand], [RegDate], [UseArea] FROM [ZDRRA] where landuser like '%Keyword%'";
SqlDataAdapter da = new SqlDataAdapter(SQLstring, MyConn);
DataSet ds = new DataSet();
da.Fill(ds);
LandView.DataSource = ds.Tables[0];
LandView.DataBind();
}
因为我财富不够,所以没有奖励了 不好意思啊!!希望大家多多帮助 展开
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ImgBtn_Click(object sender, ImageClickEventArgs e)
{
string StrConn = ConfigurationManager.ConnectionStrings["JYGConnStr"].ConnectionString;
SqlConnection MyConn = new SqlConnection(StrConn);
MyConn.Open();
if (Request.Form["Keyword"] != null)
{
Keyword.Text = Server.HtmlDecode(Request.Form["Keyword"].ToString());
}
string SQLstring = "SELECT [LandUser], [LangStand], [RegDate], [UseArea] FROM [ZDRRA] where landuser like '%Keyword%'";
SqlDataAdapter da = new SqlDataAdapter(SQLstring, MyConn);
DataSet ds = new DataSet();
da.Fill(ds);
LandView.DataSource = ds.Tables[0];
LandView.DataBind();
}
因为我财富不够,所以没有奖励了 不好意思啊!!希望大家多多帮助 展开
3个回答
展开全部
if(textbox1。text。length>0)
{
strign.format=("select...@",textbox1.text.trim());
}
或者
string sql=“select...where id=”+textbox1。text。trim();
{
strign.format=("select...@",textbox1.text.trim());
}
或者
string sql=“select...where id=”+textbox1。text。trim();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
string SQLstring = "SELECT [LandUser], [LangStand], [RegDate], [UseArea] FROM [ZDRRA] where landuser like '%'" + this.TextBox1.Text + "'%'";
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
" + Keyword.text + "
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询