string pp;
string aa;aa=this.textBox1.Text.Trim();pp="SELECT * FROM 职工 where 工资>"+aa;
sqlSelectCommand1.CommandText =pp;
string aa;aa=this.textBox1.Text.Trim();pp="SELECT * FROM 职工 where 工资>"+aa;
sqlSelectCommand1.CommandText =pp;
sqlDataAdapter adapter=new sqlDataAdapter(pp,sqlConnect);//sqlConnect 是你先设定好的数据库连接;
adapter.Fill(ds);
dataGrid1.Datasource=ds.Tables[0];
int aa;
aa=this.textBox1 .Text
pp="SELECT 学号, 姓名, 数学, 英语, 总分 FROM 成绩 where 总分>'"+aa+'"";
sqlSelectCommand1.CommandText =pp;
int aa;
aa=this.textBox1 .Text;
//错误this.textBox1.Text是string变量。
要判断textBox1的输入,如果不是数字,出现异常!!
try
{
aa = int.Parse(this.textBox1.Text);
}
catch
{
Response.Write("<script language='javascript'>alert('请输入数字!')</script>");
}
改为
pp="SELECT 学号, 姓名, 数学, 英语, 总分 FROM 成绩 where 总分>"+aa.ToString()";
sqlSelectCommand1.CommandText =pp;