Connecting to Various Data Sources
It would be impossible to include code to connect to all the possible kinds of databases. The next section shows you how to connect to Microsoft SQL Server versions 7.0 and up using the managed SQL provider in the System.Data.SqlClient namespace and also how to connect to various OLE DB data sources using the System.Data.OleDb namespace.
SQL Server
When using the managed SQL provider, do not specify the Provider keyword in your connection string. In fact, the only connection string properties you're likely to need are the ones in Table 5.1.
Connection String Property | Description |
---|---|
Initial Catalog | Specifies the database you're connecting to |
Server | Specifies the server you're ... |
Get Sams Teach Yourself ADO.NET in 24 Hours 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.