如何在数据库中显示文本框中的值?

时间:2012-02-19 09:33:20

标签: asp.net sql c#-4.0 textbox

嗨我有这样的数据库

用户表

     user_id |   username  |  branch_id(foreignkey)|  Approved_id(foreignkey)
  -------------------------------------------------------------------------------
    1          jprescott         2                          1
    2          lpausch           1                          3

分支表


Branch_id    BranchName        
1                abc                    
2               asjdv                 
3               ydgfs             

Approvetable


     ApproveId  ApprovedBy
          1         Anil
           2         ghouse
           3         raghu

现在我有3个文本框,我如何在文本框中的这些字段

          txtusername.text=username from table 1;
          txtapprovedname=approved by from table 2;
          txtbranchname=branchname from table 3;

当用户1登录时,应检查分支ID并转到分支表并显示分支名称,并检查approveid并转到approvedtable并在文本框中显示已批准的名称.....

现在如何为此编写一个select语句可以帮助我任何人帮助我............

1 个答案:

答案 0 :(得分:0)

select UsersTable.username, ApproveTable.ApprovedBy, Branchtable.BranchName
from UsersTable, Branchtable, Approvetable
where UsersTable.branch_id = BranchTable.branch_id
AND UsersTable.approved_id = ApproveTable.ApproveId
AND UsersTable.User_id = %CurrentUserID%