I am trying to write a database app with three tables. I have figured out how to connect to my database with oledbconnect. From there I am confused as to how to get a select command to work. I have found plenty of info on selecting data from one table using the SQL QUERY option. I do not want to select from one table. I want to select from two tables, for example:
select tbl1.name, tbl2.address
from table1 tbl1, table2 tbl2
tbl1.id = tbl2.id

This should not be so difficult, but it is. I am not certain if I have to do something with the dataset, data-adapter or what. I would like someone out there to give me a step-by-step as to what I need to click-and-or-drag when setting up the connection, dataset, etc. Thanks ahead of time for the expertise!

10 Years
Discussion Span
Last Post by Venjense

in your dataadapter do

OleDBDataAdapter da = new OleDBDataAdapter("select tbl1.name, tbl2.address from table1 tbl1, table2 tbl2 where tbl1.id = tbl2.id", conn);

From there, you can do a datareader or fill a datatable. As long as the join columns are of the same type, you should have no issues.

I rarely use the wizrds to create the datasource and dataadapters so I can't really help you with a step by step, but if you look at http://www.daniweb.com/techtalkforums/thread54264.html you'll get the picture.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.