Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Data Access QuickStart

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

The Data Access QuickStart application demonstrates some of the key features of the Data Access Application Block. It demonstrates these features by using a set of walkthroughs, which are implementations of the situations discussed in Key Scenarios. The following walkthroughs are provided:

This QuickStart is configured to run against a SQL Server database instance. The supplied SQL script creates the required SQL database on the local computer.

The QuickStart has the following features:

  • The scenarios are independent of each other, so you can view them in any order. Each scenario contains all of the data access code necessary to complete the scenario.
  • The code that accesses the database is contained in its own class, separate from the QuickStart form. While this class is not meant to be a true data layer, its separation illustrates that data access code should be independent of the user interface code.
  • A top-level handler catches any exceptions that occur during any of the scenarios. The handler displays a dialog box that shows the exception message(s) and a reminder to run the setup script, SetupQuickStartsDB.bat, before running the QuickStart.
  • Each button in the left-side pane of the QuickStart interface corresponds to one of the scenarios discussed in Key Scenarios. Clicking the View Walkthrough button displays the appropriate Help file. The Quit button stops the application.

The QuickStart is provided in two versions. The first uses the factory approach and the new operator to create Enterprise Library objects and other class instances. For example, it creates a SalesData instance using the new operator.

The second version demonstrates integration with the Unity Application Block. It creates and populates a UnityContainer instance with the data from the <unity> section of the configuration file. This loads the Enterprise Library Core and Data Access Application Block extensions. This QuickStart also generates the main form instance using the Resolve method of the UnityContainer, which causes Unity to create and inject the required SalesData instance in the form constructor.

For information about integration with the Unity Application Block and how you can create instances of Enterprise Library objects using Unity, see Creating Objects Using the Unity Application Block.


Before using the application, first run SetupQuickStartsDB.bat, which is located in the root directory of the Data Access QuickStarts. This batch file assumes a local SQL Server with an instance name of (local)\SQLEXPRESS. It creates a SQL Server database named EntLibQuickStarts. If you want to use a different SQL Server instance or a different server, you must manually update the scripts. The script assumes the following settings.

Server: (local)\SQLEXPRESS 
Authentication: integrated 


Ff648274.note(en-us,PandP.10).gifNote:
To successfully run the script, you must have sufficient privileges to create a SQL Server database.


The QuickStart ships as source code, which means you must compile it before running it. You use Visual Studio to build the QuickStart.

To build the Data Access QuickStart

  1. Ensure the Enterprise Library Source Code is installed.
  2. Open the Enterprise Library Source Code folder in Windows Explorer or from the Start menu. To open it from the Start menu, click Start on the taskbar, point to All Programs, point to Microsoft patterns and practices, point to Enterprise Library 4.0 — May 2008, and then click Enterprise Library 4.0 Source Folder.
  3. To run the factory version of the QuickStart, open the QuickStarts folder, open the Data folder, and then open the CS folder (for C#) or the VB folder (for Visual Basic .NET).
  4. To run the version of the QuickStart that demonstrates integration with the Unity Application Block, open the QuickStarts folder, open the Data folder, and then open the CS-UnityIntegration folder (for C#) or the VB-UnityIntegration folder (for Visual Basic .NET).
  5. Double-click the DataAccessQuickStart.sln icon.
  6. Visual Studio opens, displaying the solution file. Open the Build menu and click Rebuild Solution. By default, this is a debug build.
  7. Press F5 to run the QuickStart.

The walkthroughs in the Data Access QuickStart are shipped with a defined configuration, which is included in the App.config file. This file is located in the same folder as the QuickStart project file and has the following settings:

  • The database type is SQL Server.
  • The name of the server is (local)\SQLEXPRESS.
  • The name of the database is EntLibQuickStarts.
  • The name of the connection string is DataAccessQuickStart.
  • The Integrated Security setting is SSPI.

To change or view these settings, use one of the Enterprise Library configuration tools to open the App.config file in the directory that contains the QuickStart project file. The App.config file contains the configuration data. Each time you build the code, Visual Studio copies the App.config file to the output directory for the project (the same directory where the QuickStart executable is created) and renames it to DataAccessQuickStart.exe.config.

This means that if you want to use the configuration tools to change any of the configuration settings and you are planning to rebuild the solution, you must change the settings by opening the App.config file located in the QuickStart source directory. You can use the configuration tools to open the DataAccessQuickStart.exe.config file and change the application configuration. However, these changes will be overwritten during the next successful build.


Show:
© 2015 Microsoft