Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. ADO.NET Basics > Connected Mode

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 source=myserver;" +
  "user id=sam;password=tc8!at;initial catalog=acme");
oconn.Open();


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint