Developer .NET UPDATE, April 1, 2003

Developer .NET UPDATE—brought to you by the Windows & .NET Magazine Network.



SQL Server Magazine Connections


DevConnections = Microsoft ASP.NET Connections + Visual Studio Connections + SQL Server Magazine Connections. Three Conferences for the price of One!

Day One of the conference features "Microsoft Day" with in-depth coverage of Visual Studio .NET and ASP.NET from Microsoft product architects. It's a perfect primer to ensure you've got a handle on .NET basics and a foundational understanding of these technologies.

Day Two and Three feature our world-renown gurus, authors, and consultants. These two days will provide the attendee with additional drill downs and details about VB, VB.NET, C++, C#, ASP.NET, SQL Server, XML, CLR, .NET Framework, and .NET application development practices, tips, and insights. All total, more than 140 sessions to choose from.

Conference Co-Chair Carl Franklin explains, "My agenda was only to pick the best variety of talks on real-world topics, and to avoid the fluff...I picked the more detailed and advanced topics that attendees can immediately put into practice back at the office."

Attendees will have a chance to win a brand new Harley Davidson 100th Anniversary Sportster 883 XLH motorcycle and other cool giveaways. And if you register by April 7th, you'll save $200 on the conference registration.

Register by April 7th and you'll get:

  • $200 registration discount
  • Three great conferences for the price of one
  • Free one-year subscriptions to MSDN Magazine and Dobb's Journal
  • Free trial version of Visual Studio .NET 2003
  • Opportunity to win a brand new Harley Davidson and other cool prizes
  • Three to four days of training that will save you months of trial and error

Register online or call 800-438-6720:

April 1, 2003--In this issue:


  • The Data Access Application Block


  • Get the eBook That Will Help You Get Certified!
  • Are You Getting the Best SQL Server Resource Available?


  • Find the Lost Win32 API


  • See this section for a list of ways to contact us.


(contributed by Bill Sheldon, [email protected])

  • Last week, I discussed some of the guidance available from Microsoft related to setting up, or implementing, database access in your applications. This week, I want to introduce you to the Data Access Application Block. Similar to the Exception Management Application Block, which I discussed in the March 11 Developer .NET UPDATE (, the Data Access Application Block provides code that you can incorporate into your project to take advantage of some recommended practices for implementing data access in your application. The Data Access Application Block is available from the Microsoft Download Center at

    When you download the Data Access Application Block's .msi file, the application block installs under the \Program Files\Microsoft Application Blocks for .NET\ directory by default. The package contains a Help file in the Docs subdirectory and Visual Basic .NET and Visual C# .NET implementation code. Keep in mind that you need to use only one of these implementations, which are the same aside from the language.

    Microsoft designed both implementations to access only Microsoft SQL Server. If you intend to use another OLE DB data source or want to leverage Oracle or an ODBC connection, you're limited to using this code as a template for custom data-access logic.

    The .msi file that you download doesn't include a compiled set of the application block components (i.e., the binaries). When you install the Data Access Application Block, two classes are created as part of the Microsoft.ApplicationBlocks.Data namespace. The first class, SqlHelper, manages the actions associated with creating and executing database queries. The second class, SqlHelperParameterCache, manages the actions associated with caching the data used as parameters for stored procedure calls.

    Unlike the Exception Management Application Block, the Data Access Application Block's SqlHelper and SqlHelperParameterCache classes are fully compatible with Xcopy-command deployments. Both classes are implemented exclusively with static (i.e., Visual C# .NET) or shared (i.e., Visual Basic .NET) methods. If you use static methods, after you compile these classes and add a reference to the resulting DLL, you can have your application call the various methods without creating instances of those classes. I recommend that you create a separate DLL for these classes instead of mixing the source code from the Data Access Application Block with the source code in your application. Creating a separate DLL doesn't mean that you can't customize the SqlHelper and SqlHelperParameterCache classes. If you want your application to use only stored procedures to access the database or to meet some other internal requirement, you can customize the classes before compiling them.

    The SqlHelper class offers a series of overloaded methods that support various activities. For example, the ExecuteDataset method has nine signatures. In each case, the method returns a data set. The various implementations of this method support everything from a connection string to an open transaction as the starting point for the request. As you prepare to work with your application, you might want to limit the options available to your application. When Microsoft designed the Data Access Application Block, the underlying goal was to let developers customize the SqlHelper class. Developers can, for example, pass a connection string or a connection object as part of a request for a data set.

    Deciding whether to pass a connection string or connection object is a decision that you ideally make during the design phase before you publish your custom version of the Data Access Application Block. The advantage of using connection strings is that they let you rely on the application block to manage opening and closing database connections. The disadvantage is that if your application logic needs to execute several different stored procedures in succession, you'll be recreating the connection object and reopening the same connection several times. Although connection pooling can help address performance concerns, if you know in advance this situation will commonly occur, you might want to pass a connection object instead of letting the application block manage these activities. However, given your development cycle, you might not be concerned about which of the overloaded method signatures you implement as long as you leverage the logic associated with the application block.

    The SqlHelperParameterCache class relies only on static functions. In other words, it doesn't cache the parameter values. This class provides common methods for manipulating an array of SqlConnection parameters. You still need to declare the array of parameters in your application, but instead of needing to write code that adds and removes parameters to the array, you can use this class to discover and manage the parameters.

    SQL Distributed Management Objects (SQL-DMO) is a collection of objects that let you programmatically manage SQL Server's database, scheduling, and replication capabilities. If you've participated in any of my Microsoft Developer Network (MSDN) Webcasts, you might have heard me talk about how Microsoft didn't implement many of the SQL-DMO objects in the Windows .NET Framework. However, the Framework does provide the ability to retrieve information about database objects, such as retrieving the parameter list for a stored procedure. The SqlHelperParameterCache class provides methods to retrieve parameter lists so that you don't need to become familiar with this capability. The result is that you can create applications that use metadata to create custom grids. The application code retrieves the name of the stored procedure from a table, retrieves the necessary parameters, then on the fly, passes this information to the stored procedure so that the stored procedure can execute.

    In most organizations, developing the underlying classes to support the type of metadata-based retrieval that the Data Access Application Block supports can take weeks or even months. By taking advantage of the Data Access Application Block, you can start to leverage code that Microsoft has already tested and quickly create advanced capabilities in your application.



    Don't miss this chance to attend three power-packed events for the price of one. Microsoft ASP.NET Connections + Visual Studio Connections + SQL Server Magazine Connections equals the largest gathering of Microsoft product architects and independent Tech gurus, delivering four days of hard-core drill-down sessions that you will not find anywhere else.

    SQL Server Magazine writer Brian Moran serves as this year's conference chair for the SQL event. Brian has planned sessions for DBAs, SQL developers, DataWarehouse/BI architects, and DataAccess specialists. Expert speakers include world renown gurus such as Kaylen Delaney, Bill Vaughn, Morris Lewis, Fernando Guerrero, Kimberly Tripp, Ron Talmage, Microsoft's Gert Drapers, and more.

    Get the latest roadmap for SQL Server as Microsoft's Director of SQL Server Product Management, Stan Sorenson, opens the conference with his keynote address.

    Attendees receive a free one year subscription to SQL Server Magazine and have a chance to win a brand new Harley Davidson 100th Anniversary Sportster 883 XLH motorcycle. If you register by April 7th, you'll save $200 on the conference registration.

    Great content, great experience, great giveaways. Don't miss this high value event.

    Register online or call 800-899-5325:

    (brought to you by Windows & .NET Magazine and its partners)

  • The Insider's Guide to IT Certification, from the Windows & .NET Magazine Network, has one goal: to help you save time and money on your quest for certification. Find out how to choose the best study guides, save hundreds of dollars, and be successful as an IT professional. The amount of time you spend reading this book will be more than made up by the time you save preparing for your certification exams. Order your copy today!

  • Subscribe right now to SQL Server Magazine and receive 12 information-packed issues delivered to your doorstep or your desktop, and you'll get free access to the entire SQL Server Magazine article archive on the Web during your subscription term. You have nothing to lose and there's absolutely no risk.

    (contributed by Sue Cooper, [email protected])

  • Sybex announced the release of .NET Framework Solutions: In Search of the Lost Win32 API, by John Paul Mueller, a guide to dealing with the functionality not included in the Windows .NET Framework. The book offers discussions on direct hardware access, low-level security control, certain aspects of OS access, support for multimedia and utilities, and DirectX. Special attention is paid to managing memory manually. .NET Framework Solutions: In Search of the Lost Win32 API is available from Sybex for $59.99 or $47.99 if you buy it online.

    Here's how to reach us with your comments and questions:

    • ABOUT DEVELOPER .NET PERSPECTIVES -- [email protected]
    • ABOUT THE NEWSLETTER IN GENERAL -- [email protected] (please mention the newsletter name in the subject line)
    • PRODUCT NEWS -- [email protected]
    • QUESTIONS ABOUT YOUR DEVELOPER .NET UPDATE SUBSCRIPTION? Email Customer Support -- [email protected]
    • WANT TO SPONSOR DEVELOPER .NET UPDATE? [email protected]
    • This weekly email newsletter is brought to you by Windows & .NET Magazine, the leading publication for Windows professionals who want to learn more and perform better. Subscribe today.

      Receive the latest information about the Windows and .NET topics of your choice. Subscribe to our other FREE email newsletters.

    Hide comments


    • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

    Plain text

    • No HTML tags allowed.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Lines and paragraphs break automatically.