tailieunhanh - Setting Connection Pooling Options
[ Team LiB ] Recipe Setting Connection Pooling Options Problem You need to know the different connection pooling options and how you can control them. Solution Use the connection string to control connection pooling for the SQL Server, OLE DB .NET, Oracle, or data provider. | Team LiB Recipe Setting Connection Pooling Options Problem You need to know the different connection pooling options and how you can control them. Solution Use the connection string to control connection pooling for the SQL Server OLE DB .NET Oracle or data provider. The sample code contains a method and four event handlers Creates a Connection attaches an event handler to its StateChange event and sets default properties for controls on the form that are used to specify connection properties. The UpdateConnection method is called to dynamically construct a connection string from the specified properties. UpdateConnectionString This method dynamically constructs a connection string from the connection string properties specified by the user in text boxes on the form. This method is called to update the connection string when the user changes the value of any of the controls used to specify connection string properties. Open Opens the Connection that is based on the connection string constructed in the UpdateConnectionString method. Close Closes the connection string. Displays original and current state information about the connection when its state changes. The C code is shown in Example 1-11. Example 1-11. File Namespaces variables and constants using System using using using using private SqlConnection conn . . . private void ConnectionPoolingOptionsForm_Load object sender e conn new SqlConnection new StateChangeEventHandler conn_StateChange S ql_ConnectString 15 0 0 100 true UpdateConnectionString private void UpdateConnectionString .
đang nạp các trang xem trước