使用一个表的引用并从另一表获取数据 [英] use reference of one table and get data from other table

查看:79
本文介绍了使用一个表的引用并从另一表获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!
我有两个不同的表.临时的,生动的.
临时表包含所有在线的用户名.并且pictable包含所有已注册用户的图片.
现在我有一个index.aspx页面,其中包含gridview
我要的是在页面加载时检查模板,并为模板中存在的所有用户拍照并在gridview中显示它.
请告诉我该怎么做.
在此先感谢

Hi!
i have two different tables. temptable, pictable.
the temptable contains all those usersname whos are online. and pictable contains pictures of all the users who are registered.
now i have an index.aspx page it contains gridview
what i want is to when the page loads it checks the temptable and take pictures of all those users that are present in temptable and show it in gridview.
please tell me how to do it.
thanks in advance

推荐答案

temptable应该包含userid(主键),它是pictable中的引用键

例如

临时表:
userid(主键)
用户名
图片:
用户ID(外键)
图片

然后添加gridview并分配具有查询的sqldatasource

选择t.username,p.image
从temptable t加入pictable p
在t.userid = p.userid
temptable should contains userid (primary key) which is reference key in pictable

for example

temptable:
userid (primary key)
username
pictable:
userid(foreign key)
image

Then add gridview and assigned sqldatasource which has query

Select t.username,p.image
from temptable t join pictable p
on t.userid=p.userid


这篇关于使用一个表的引用并从另一表获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆