stringyear=tB_BirthScan.Text.Trim();using(SqlConnectionscon1=newSqlConnection("server=LGX-PC;Database=Student;IntegratedSecurity=true")){scon1.Open();DataSetds=newDataSet...
string year = tB_BirthScan.Text.Trim();
using (SqlConnection scon1 = new SqlConnection("server = LGX-PC;Database = Student;Integrated Security=true"))
{
scon1.Open();
DataSet ds = new DataSet();
SqlDataAdapter sd = new SqlDataAdapter("select * from Table_Stu where substring (StuBirthday,1,4)=year", scon1);
sd.Fill(ds, "Table_Stu");
this.dataGridView_Show.DataSource = ds.Tables[0];
}
我想通过根据文本框string year = tB_BirthScan.Text.Trim();获得字符串year
然后将year 作为参数执行SqlDataAdapter sd = new SqlDataAdapter("select * from Table_Stu where substring (StuBirthday,1,4)=year", scon1);
请问该怎么做
展开