Gridview显示数据的问题 在线等 谢谢 简单
我有2个表 kehu 和 xiaoshou
表xiaoshou的字段kid和表kehu的kid关联
用GridView显示表xiaoshou的数据
其中字段kid想显示表kehu相关联的name字段
该怎么做??
------解决方案--------------------在sqlserver2000的 视图中创建一个视图 然后添加表 然后查询视图就行了
------解决方案--------------------select 各字段名称 from xiaoshou and name from kuhu where kuhu.kid=xiaoshou.kid
------解决方案--------------------写个存储过程就搞定了
数据源 : select xiaoshou.?,kehu.name where xiaoshou.kid = kehu.kid
------解决方案--------------------select name as kid from xiaoshou, kuhu where kuhu.kid=xiaoshou.kid
------解决方案--------------------select a.kid,b.name from xiaoshou a inner join kehu b on a.kid=b.kid
------解决方案--------------------感觉5楼的方法更好些,用inner join就可以
------解决方案--------------------select a.kid,b.name from xiaoshou a left join kehu b on a.kid=b.kid
------解决方案--------------------用外连接更好
------解决方案--------------------select kehu.name as kid,xiaoshou.各字段名 from xiaoshou, kuhu
where xiaoshou.kid = kehu.kid
------解决方案--------------------[字段kid] [显示] 表kehu相关联的[name字段]
___________________________
lz的意思的主谓宾 应该是上面的意思吧
------解决方案--------------------select xiaoshou.(想要显示的表xiaoshou中的字段),kehu.name from xiaoshou inner join kehu on xiaoshou.kid=kehu.kid