0% found this document useful (0 votes)
88 views

m03 Connection Slides PDF

The document discusses .NET data providers for connecting to different data sources using ADO.NET, including SqlClient for SQL Server, OleDb for data sources like Excel and Access, and Odbc for ODBC compliant sources. It provides examples of minimum connection strings for SqlClient and OleDb, and describes some common connection string options like encryption, timeouts, and connection pooling. The document concludes with an overview of using connection strings and managing database connections in ADO.NET applications.

Uploaded by

biplobusa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

m03 Connection Slides PDF

The document discusses .NET data providers for connecting to different data sources using ADO.NET, including SqlClient for SQL Server, OleDb for data sources like Excel and Access, and Odbc for ODBC compliant sources. It provides examples of minimum connection strings for SqlClient and OleDb, and describes some common connection string options like encryption, timeouts, and connection pooling. The document concludes with an overview of using connection strings and managing database connections in ADO.NET applications.

Uploaded by

biplobusa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Connect to a data source using ADO.

NET

Herve Roggero

[email protected]
.NET Data Providers

 System.Data.SqlClient
 SQL Server and Windows Azure SQL Database (SQL Database, SQL Azure)
 System.Data.OleDb
 OLE DB data sources such as Excel and MS Access
 System.Data.Odbc
 ODBC data sources such as a text file or any ODBC compliant data source
 System.Data.OracleClient
 Oracle 8.1.7 or later

http://tinyurl.com/matauor
Connection String for SqlClient

 Recommended minimum connection string with network security


 Server=localhost; Initial Catalog=master; Integrated Security=true
 Server=localhost; Initial Catalog=master; Integrated Security=SSPI
 Recommended minimum connection string with SQL Login
 Server=localhost; Initial Catalog=master; User Id=userid; Password=xyz
 Server=localhost; Initial Catalog=master; UID=userid; PWD=xyz
 About the Server keyword
 Can contain the protocol used to connect (tcp, np, rpc, lpc…)
 Can be an IP Address, a server name
 Can contain a Port number (default 1433)
 Can specify a named instance of SQL Server
 Ex:
 Server=[protocol:]SERVER_OR_IP[\instancename][,port]
 Server=tcp:DEVDSK02\SQL2012,5000
A Few Connection Options for SqlClient

 SSL Encryption for the duration of the session


 Encrypt=true (default false)
 Connection timeout when waiting for a connection
 Connection Timeout=60 (default 15)
 Application name description
 Application Name=‘ADO.NET Demo Application’
 Connection pooling maximum size
 Max Pool Size=200 (default 100)

http://tinyurl.com/5qlua5
Connection String for OleDb

 Minimum connection string for SQL Server


 Provider=sqloledb; Data Source=localhost; Initial Catalog=master ; User
Id=userid; Password=xyz
 Minimum connection string for Excel
 Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\myexcelfile.xls;
 Additional settings for Excel
 HDR=Yes means that the first row contains headers
 IMEX=1 reads all data as text

http://tinyurl.com/mwj33ub
Conclusion

 Connection String basic requirements


 Overview of SqlClient
 Overview of SqlConnectionStringBuilder
 Opening database connections
 Looking at established connections using T-SQL

You might also like