Results 1 to 1 of 1
Jun 15, 2011, 08:26 #1
- Join Date
- Jun 2011
- 0 Post(s)
- 0 Thread(s)
Displaying data from join table based on dynamic dropdown box
New to this: I am using ASP.net/visual web developer to put together a site with MS Sql Server 2008 express edition backend.
I have a dropdown box populated with the baseline data (Table1) that everything else feeds off of. So I have several tabs on my webpage with different data from several tables that populate dynamically based off a choice made from the dropdown box at the top of the page. I now want to add points of contact to this. The problem is that Table2 data and Table1 data are a many to many relationship. So I created the join table. Now I can display the data from both tables statically no problem. But I want to tie this data to the dropdown choice. So when I make a choice from the dropdown box I get only the point of contacts(data in Table2) associated with that particular choice. All of my other Data Tables do this with no problem with this: ‘WHERE (columnA = @columnA)’ in the Table Adapter (no link tables).
However with the join table in between TableA and TableB when I try and use the WHERE clause it comes out like this:
WHERE (Table1.columnA = Table1.columnA). I tried to add the @ to this but the query fails. Is there a way to do this?
Current Sql statement that works to display the data statically:
SELECT table1.columnA, table2, columnA, table1primarykey, table2primarykey
FROM Linktable INNER JOIN
Table2 ON Linktable.table2primarykey = table2primarykey INNER JOIN
Table1 ON Linktable.table1primarykey = table1primarykey
WHERE (Table1.columnA = Table1.columnA)
So is there a query filter that I can use to allow what I want? Or am I using the JOIN improperly? Any help would be greatly appreciated. Thanks.