select * from tablename where columnname like '07%'
select dormitoryColumn from tableName where dormitoryColumn like '07%' //查找宿舍列以07开头的信息
楼主没必要放到两个DataSet当中,查找出来放到一个DataSet里,之后检索不同的数据即可。
select * from tablename where columnname like '07%' select * from tablename where columnname like '073%'
create table a( ssid nvarchar(20) )insert into a select('12115') union all select('0717') union all select('1216') union all select('07317') union all select('07553') union all select('076') union all select('07')DataSet ds = new DataSet(); using (SqlConnection conn = new SqlConnection("server=.;user id=sa;password=;database=testDb;")) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from a where ssid like '07%'"; SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; adapter.Fill(ds); }//以07开头的结果集为基础,进一步筛选 DataView dv =new DataView(); dv.Table = ds.Tables[0]; dv.RowFilter = "ssid like '073%'";//打印 07开头的结果集 GridView1.DataSource = ds.Tables[0]; GridView1.DataBind();//打印 073开头的结果集 GridView2.DataSource = dv; GridView2.DataBind();
select dormitoryColumn from tableName where dormitoryColumn like '07%'
//查找宿舍列以07开头的信息
select * from tablename where columnname like '073%'
ssid nvarchar(20)
)insert into a
select('12115') union all
select('0717') union all
select('1216') union all
select('07317') union all
select('07553') union all
select('076') union all
select('07')DataSet ds = new DataSet();
using (SqlConnection conn = new SqlConnection("server=.;user id=sa;password=;database=testDb;"))
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from a where ssid like '07%'";
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
adapter.Fill(ds);
}//以07开头的结果集为基础,进一步筛选
DataView dv =new DataView();
dv.Table = ds.Tables[0];
dv.RowFilter = "ssid like '073%'";//打印 07开头的结果集
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();//打印 073开头的结果集
GridView2.DataSource = dv;
GridView2.DataBind();