TAILIEUCHUNG - Changing the Database for an Open Connection

[ Team LiB ] Recipe Changing the Database for an Open Connection Problem You want to change the database that a connection uses without recreating the connection. Solution Use the ChangeDatabase( ) method to change the database for a connection. | Team LiB Recipe Changing the Database for an Open Connection Problem You want to change the database that a connection uses without recreating the connection. Solution Use the ChangeDatabase method to change the database for a connection. The sample code creates a Connection to the Northwind database using the SQL Server .NET data provider. The connection is changed to use the pubs database. Finally the connection is closed. The Database property of the SqlConnection object is displayed throughout the sample for the different connection states. The C code is shown in Example 1-12. Example 1-12. File Namespaces variables and constants using System using using using using . . . StringBuilder result new StringBuilder Create the connection accessing Northwind database. SqlConnection conn new SqlConnection Sql_ConnectString Connection String Open the connection. Database Change the database to pubs. pubs Database Close the connection. Database Discussion The ChangeDatabase method is defined in the IDbConnection interface that represents a connection to a data source and is implemented by .NET data providers for relational databases including those for SQL Server Oracle and OLE DB. The ChangeDatabase method is used to change the current database for an open connection. It takes a single parameter that specifies the name of the database to use in place of the current database. The name of the database must be valid or .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.