猿问

VS2008 gridview 查询的2个问题

有一表 student

有学号,姓名2列

有textbox1,textbox2,button控件

3个参数 a,b,c;a,b为textbox1,textbox2 的控件返回值, 设c值为%

为什么select * from table where name like %@b%  不可以查询,而

select * from table where name like @c+@b%+@c  就可以呢

还有 select * from table where (name = @c+@b%+@c   OR num=@a  )  为什么不行(通过学号或名字查信息)

再加个问题,gridview 数据源为SqlDataSource1 ,有办法使点按钮1时数据源为SqlDataSource1,而点按钮2时数据源为SqlDataSource2吗?

或者 按不同按钮时  SqlDataSource 的SelectCommand发生变化,谢谢


慕的地8271018
浏览 411回答 2
2回答

呼如林

sql语句参照上面,至于换数据源,你可以用控件事先做好两个datasource,然后在按钮的click事件里给gridview指定数据源就行,gridview.datasource=sqldatasourceX;

POPMUISE

sql语句参照上面,至于换数据源,你可以用控件事先做好两个datasource,然后在按钮的click事件里给gridview指定数据源就行,gridview.datasource=sqldatasourceX;
随时随地看视频慕课网APP
我要回答