I am trying to find a way to dynamically determine/reference a table name based on a value in another table.
In concept this is what I want:
SELECT * FROM TTestCase
WHERE TTestCase.ElementNo = (
SELECT TControlTables.ControlTable from TControlTables
WHERE TControlTables.MessageType in (
SELECT TTestCaseParameter.MessageType
FROM TTestCaseParameter).ElementNo
The “SELECT TControlTables.ControlTable from TControlTables
WHERE TControlTables.MessageType in (SELECT TTestCaseParameter.MessageType FROM TTestCaseParameter” is the query that determines which table’s ElementNo should be compared with the TestCase.ElementNo.
Some very rough notes, you will get much better code here http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommand(v=vs.71).aspx. Hopefully, this will start you off.