May 2004
Intermediate to advanced
888 pages
22h 31m
English
To open a connection to the data store, you simply invoke the SqlConnection.Open() method. Likewise, to close the connection, invoke the SqlConnection.Close() method.
Note
If connection pooling is supported, opening a connection will try to use a connection from the pool; otherwise, a new connection is established to the data store. Also, closing a pooled connection adds the connection to the pool instead of actually closing it. Connection pooling is discussed later in this chapter.
Listing 18.1 illustrates the opening and closing of a SQL Server connection.
1: program test; 2: {$APPTYPE CONSOLE} 3: uses 4: System.Data.SQLClient; 5: const 6: CNSTR = 'server=localhost;database=Northwind;Trusted_Connection=Yes'; ... |
Read now
Unlock full access