Sdp Sdp - 2 months ago 8
C# Question

Retrieve data from two table

I have two tables

tblRegistration(id,name,program,regdno,address)
and
tblDue(id,regdno,amountdue)
. What I want is to pass regdno from a
textbox
and then retrieve the
name
,
program
values form
tblRegistration
and
amountdue
from
tblDue
.

What i tried is ,

select t1.name,t1.program, t2.amountdue
from tblRegistration as t1
inner join tblDue as t2 on t2.regdno= t1.regdno;


It returns all values having same
regdno
in both tables.

Help me on getting those values only whose
regdno
I provide from textbox.

Sorry for the language. Thank you in advance.

Answer

Modifiy your query sql like this:

 select t1.name,t1.program, t2.amountdue from tblRegistration as t1 inner join tblDue as t2 on t2.regdno= t1.regdno
 where t1.regdno=yourvaluetestbox;