DataAdapters and Component Surfaces (or why I love using the toolset)
I always forget this blog this, but when I am doing a database project using Typed DataSets, I almost always use a Component Surface to build my DataAdapters interactively. For example:
Here I add a component to my project:
Once I do this, I have a component surface to drop Data Adapters onto:
Now I can drop a Data Adapter (doesn't matter which kind) onto the surface to start the DataAdapter wizard (don't grimace, it's quite safe):
Within this wizard you can specify the connection, the SQL (or more appropriately, the stored procedures, or with SQL Server you can even have them make you Stored Procedures). Once you press finish, you'll have a data adapter and a connection string in on your design surface:
Next you can modify the properties of the data adapter to make it publically available (I'll show you what that means in just a minute):
Then you can specify the TableMappings (and consequently the Column Mappings):
This brings up the Mapping dialog where you can use a Typed DataSet to suggest the mappings:
Now you have a class that contains the DataAdapter. You would use it like so:
Adapters adapters = new Adapters(); adapters.sqlDataAdapter1.Fill(myDataSet);
Making the adapter public lets us call it from an instance of the component class. If you want to use my DataSet updater class (see http://wildermuth.com/content.aspx?id=rantview&rantid=156), you can use each of the adapters in series.
When I use this approach, I usually create an adapter for each type of Get operation I have (e.g. GetCustomers, GetCustomerByName, GetCustomerByID, GetCustomerByRegion). I then create an Adapter for each Table that will be updated. This allows my "Get" adapters to use batch queries to streamline the retrieval.
Hope this help...