O'Reilly logo

Essential ADO.NET by Bob Beauchemin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required