Monthly Archives: May 2008

Binding to joined tables

Many times it is necessary to bind to a datatable which is made up of multiple database tables.  Most databases are normalized.  In Visual Studio 2005 there was a particular technique to do this.  Write your join statements in stored procedures, and create a table adapter within the dataset designer to use these stored procedures for update/delete and so forth. 

With the advent of LINQ to SQL, there is a new way.  First, create your objects, and then bind directly to a LINQ query. Note however that when binding to a LINQ query, the information is read-only. If you want a read-write binding to multiple database tables, a table adapter wired up to stored procedures for SELECT, INSERT, UPDATE, and DELETE commands is still the best way to accomplish this.