Chapter 17. .NET

In the beginning of 2002, Microsoft introduced a new initiative called .NET that radically changed the Microsoft programming world. Microsoft .NET programs run on top of a runtime environment called the Common Language Runtime. Microsoft .NET provides a consistent programming model across desktop and web applications and across development languages. In this new development world, many of the old ways of programming have been thrown out the window. Microsoft .NET minimizes "DLL hell" and no longer uses the registry to install programs. All languages that run under .NET share common systems for data types, accessing data, security, garbage collection, and exception handling.

Access 2003 and earlier versions of Access, however, do not live in the world of .NET. Instead, they live in the world of the Component Object Model, or COM. By default, a COM-based program does not know how to talk to a .NET-based program. Fortunately, Microsoft created a mechanism for .NET to interoperate with the older COM-based world.

In this chapter you will find various examples that demonstrate how .NET and Access can coexist. You'll learn how to call a .NET component from Access, even when there are potentially incompatible features present in the component. You'll explore how to connect to an Access database to retrieve and update data. You'll see how to call .NET web services from Access. You'll learn how to call .NET web services that return both simple data types and complex data types. Finally, you'll learn how to automate Access from a .NET application in order to print an Access report.

The topics in this chapter all require the presence of the .NET Framework 1.1 and Visual Studio .NET 2003. If you do not have Visual Studio .NET 2003 (or a later version of Visual Studio .NET) installed on your system you will be unable to work through the topics in this chapter. See the Preface for advice on where to find free or evaluation editions of both tools.