Click here to Skip to main content
16,008,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to write method like this:
get id from one table in DB, then select related firstName and lastname from another table,then return firstname and last name to show in textbox.
2 tables have relationship on id.

thanks
Posted
Comments
[no name] 9-Mar-12 20:21pm    
Well that is going to depend on what you are basing the selection of the ID on. You have to have someway to select that first.
FM7 9-Mar-12 21:57pm    
what is mean?

Here is the sample code:

C#
var result = from p in db.table1
               join item in db.table2 on p.ID equals item.ID
               select new
               {
                   p.ID,
                   p.FirstName,
                   p.LastName,
               };
foreach (var info in result)
{
   textbox1.Text = info.FirstName + info.LastName
}
 
Share this answer
 
Hi,
write following query

select FirstName,LastName from table1 where id=(select id from table2 where ---your condition---)
hope it will help
 
Share this answer
 
select FName,LName from Table1 A inner join Table2 B on B.ID=A.id where B.ID='your id here '

after that pass this value from front enter by manually user enter by selecting value from dropdown
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900