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, 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...

Shawn Wildermuth
Author, Teacher, and Coach

My Courses

Wilder Minds Training
Vue.js by Example (New Lower Price)
Bootstrap 4 by Example (New Lower Price)
Intro to Font Awesome 5 (Free Course)
Building an API with ASP.NET Core (New Course)
Building a Web App with ASP.NET Core, MVC6, EF Core, Bootstrap and Angular (updated for 2.2)
Less: Getting Started (New)
Using Visual Studio Code for ASP.NET Core Projects
Implementing ASP.NET Web API

Application Name WilderBlog Environment Name Production
Application Ver v4.0.30319 Runtime Framework x86
App Path D:\home\site\wwwroot\ Runtime Version .NET Core 4.6.27617.04
Operating System Microsoft Windows 10.0.14393 Runtime Arch X86