Click here to Skip to main content
15,905,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two tables . One for item and another for itempermission .
Items contain fields : itemid,itemname,companyname
and itempermission contains fields : permissionid,adminid,productid.

I want to bind those fields of item table whose productid present in the itempermission through Grid View .
Posted

Hi,

try this query for joinning two tables based on condition

SQL
   select I.itemid,I.itemname from Item as I,itempermission as IP
where I.itemid=IP.productid


After that bind result to gridview

All the Best
 
Share this answer
 
Comments
Muralikrishna8811 7-Oct-11 6:55am    
what is the error
Vimalrashamra 7-Oct-11 7:02am    
NullRefrence Exception Error

in this line : if (productTable.Tables["Products"].Rows.Count == 0)
Muralikrishna8811 7-Oct-11 7:06am    
try query in sqlserver directly
Vimalrashamra 7-Oct-11 7:13am    
In sqlserver its working
Muralikrishna8811 7-Oct-11 8:12am    
you getting data by that query in sqlserver
you can write join query. use this one

SQL
select I.itemid,I.itemname,I.companyname from Item I Inner join itempermission IP on I.itemid=IP.productid
 
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