ASP.NET 2.0 DEMYSTIFIED phần 8

bởi một người truy cập vào trang web của bạn. Vòng tròn tối khi khách truy cập chọn nút radio, nếu không, vòng tròn không phải là tối tăm. Nút radio có liên quan được tổ chức thành một nhóm. Chỉ có một nút radio trong nhóm có thể được lựa chọn. | CHAPTER 10 Interacting with Databases Throughout this chapter we ll be showing examples that use SqlClient to interact with the Microsoft SQL Server and used to interact with Microsoft Access. Techniques used in these examples are similar to the way you use the other namespaces to interact with other DBMSs. Although each namespace refers to different classes there are similarities among them. For example SqlConnection is used to open a DBMS connection using the namespace. OleDbConnection performs the same task when using the namespace. Likewise SqlCommand is used to send a query to the DBMS in the System . namespace. OleDbCommand does the same using the .OleDb namespace. Opening a Connection to a DBMS Your application must open a connection to the DBMS before sending or requesting data from the DBMS. Think of a DBMS connection as the same as a telephone connection. Before you can talk to your friend you must dial your friend s telephone number and wait for her to answer. You talk as long as you want once the connection is made and you close the connection after you are through enabling someone else to connect to your friend. To create a connection to the DBMS follow these steps 1. Import the namespace This identifies the set of classes that you ll be using within your application to interact with the database. Developers import the namespace so that they don t have to write the fully qualified class name which is much longer than if the namespace is imported. 2. Create an instance of the connection class Remember from Chapter 2 that a class definition describes a class much as a stencil describes a letter of the alphabet. You create a real object described by the class by creating an instance of the class. This is similar to using the stencil to create a real letter of the alphabet. 3. Open the connection You do this by calling an appropriate instance function of the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
62    156    1    26-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.