The error in the second half of the program is that the column name a is invalid, but my idea is that a is a parameter

CSDN Q & A 2022-01-15 02:37:35

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

 } protected void Inquire about _Click(object sender, EventArgs e) { String ConnStr = "Data Source=DESKTOP-3IT6TKJ;Initial Catalog= League tables ;Integrated Security=True"; SqlConnection conn = new SqlConnection(ConnStr); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT * from Historical table by section WHERE fraction = '" + fenshu.Text.Trim() + "'"; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); //this.Update(dr); this.GridView3.DataSource = dr; this.DataBind(); //this.GridView3.DataSourceID = null; } protected void GridView3_SelectedIndexChanged(object sender, EventArgs e) { } protected void Enter the score _TextChanged(object sender, EventArgs e) { } protected void fenshu_TextChanged(object sender, EventArgs e) { } protected void xuexiao_Click(object sender, EventArgs e) { String ConnStr = "Data Source=DESKTOP-3IT6TKJ;Initial Catalog= League tables ;Integrated Security=True"; SqlConnection conn = new SqlConnection(ConnStr); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; int a; a=int.Parse(qujian.Text .Trim()); // cmd.CommandText = "SELECT * from History table WHERE fraction > '" + fenshu.Text.Trim() + "'+"qujian.Text.Trim()"and fraction < '" + fenshu.Text.Trim() + "'+"qujian.Text.Trim()" "; cmd.CommandText = "select * from Physical watch where Minimum score for filing >'" + fenshu.Text.Trim() + "' -a and Minimum score for filing <'" + fenshu.Text.Trim() + "'+a"; //cmd.CommandText = "select * from Physical watch where Minimum score for filing >'" + fenshu.Text.Trim() + "'- 5 and Minimum score for filing <'" + fenshu.Text.Trim() + "'+ 5"; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); this.GridView4.DataSource = dr; this.DataBind();

img


thank
Similar articles

2022-01-15

2022-01-15