Enterprise Library 2.0 hands on Lab translation (1): Data Access Program block (i)

Source: Internet
Author: User
Tags visual studio

Exercise one: Use a data access program block to execute a static SQL statement

This exercise demonstrates how to use the data access block for the most basic data access, and how to configure the program block to provide runtime and then select the database.

First step

Open the SimpleData.sln project, the default installation path should be C:\Program Files\Microsoft Enterprise Library January 2006\labs\cs\data Exercises\ex01\begin, and compiled.

The second step is to create the QuickStarts database

1. Open Dataaccessquickstarts.sql with Notepad, the default installation path should be C:\Program Files\Microsoft Enterprise Library January Data, select File | Save as a menu and select the encoding format encoding for Unicode, save and overwrite the original file and read-only property, remove the read-only property from the file properties.

2. Under the same directory, run the Setupquickstartsdb.bat batch file, and note that the database will be installed under the default instance (local) \SQLExpress, and if you need to change it, Use Notepad to open the Setupquickstartsdb.bat file for modification.

Third Step Review Application

Select MainForm.cs file in Visual Studio 2005 Solution Manager, select View | Designer menu, the application contains a DataGrid and several menus, and we will use the data Access Application block to count the number of customer in the database and load the data into the DataGrid.

Step fourth to implement the Customer menu item

1. Select the Customermanagment project, select Project | Add Reference ... menu command, select Browse in the Open dialog box, and add the following two assemblies.

Microsoft.Practices.EnterpriseLibrary.Common.dll

Microsoft.Practices.EnterpriseLibrary.Data.dll

The default location should be the C:\Program Files\Microsoft Enterprise Library January 2006\bin.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.