2.3. Connected Mode
The Connection class in connected mode represents a connection to a data store that uses a proprietary protocol. The connection string identifies which data store the user wishes to log on to and identifies the user. (User is an antiquated term in a three-tier scenario; usually, the “user” is a service agent and not the end user.) The following code opens a database connection through the SqlClient and OleDb data providers. This code will look familiar if you've used a data access API.
// open a connection to SQL Server SqlConnection sconn = new SqlConnection( "server=myserver;uid=sam;pwd=tc8!at;database=acme"); sconn.Open(); // open a connection to SQL Server OleDbConnection oconn = new OleDbConnection( "provider=sqloledb;data ...
Get Essential ADO.NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.