The classes of the Advantage .NET Data Provider are instantiated in these examples at runtime rather than being placed and configured at design time. While Visual Studio and Delphi for .NET permit you to place and configure data access components such as AdsConnections, AdsDataAdapters, and DataSets at design time, we do not recommend designing Windows forms and Web forms applications using this technique.
Some developers disagree with this approach. These developers correctly point out that the code generated by IDEs when you place and configure your data access components at design time saves you a lot of time coding and simplifies the maintenance of your applications.
Our position, and one that is shared by many in the .NET database community, is that when you use design-time placement and configuration, you have little control over the generated code, and the results scale very poorly. But whether or not you agree with this approach, the examples in this chapter do a good job of demonstrating how to create, configure, and control ADO.NET-related classes programmatically.
One final note deserves mention. While we used Visual Studio to create this example, it could just as well have been built using Delphi for .NET (using the Delphi language and syntax). Not only does Delphi for .NET provide you with access to the entire .NET framework class library, it provides you with access to the visual component library (VCL) for .NET and the runtime library (RTL) for .NET.
CODE DOWNLOAD: The examples provided in this chapter can be found in the C# project CS_ADONET_2003 and CS_ADONET_2005 available with this book's code download (see Appendix A). These projects were written in Visual Studio 2003 and Visual Studio 2005, respectively. If you are working with an older version of Visual Studio, project format incompatibilities will prevent you from compiling these projects.
The main form of the CS_ADONET C# project used in the examples in this chapter is shown in Figure 18-3.
Figure 18-3: The CS_ADONET project in Visual Studio 2005
Note that before you can use Advantage with Visual Studio for .NET (or Delphi for .NET), you must add a reference to the Advantage.Data.Provider assembly. To do this, use the following steps:
1. From a Visual Studio .NET project, select Projects | Add Reference. Visual Studio displays the Add Reference dialog box.
|2.||Select Advantage.Data.Provider and click Select.|
|3.||Click OK to close the Add Reference dialog box.|