ADO.NET connection database string summary of Oracle SqlServer Access ODBC

  • 2020-05-17 05:05:19
  • OfStack

ADO.NET

Connect to SQL Server
The SQL Server.NET Framework data provider supports connection string formats similar to OLE DB (ADO) connection string formats.

using (SqlConnection connection = new SqlConnection(connectionString)) 
{ 
connection.Open(); 
// Do work here. 
} 

Connect to the OLE DB data source
The OLE DB.NET Framework data provider provides connections through the OleDbConnection object to data sources exposed using OLE DB and to Microsoft SQL Server 6.x or earlier (through the OLE DB provider (SQLOLEDB) for SQL Server).

using (OleDbConnection connection = new OleDbConnection(connectionString)) 
{ 
connection.Open(); 
// Do work here. 
} 


Connect to the ODBC data source
The ODBC.NET Framework data provider provides connections through OdbcConnection objects to data sources exposed using ODBC.

using (OdbcConnection connection = new OdbcConnection(connectionString)) 
{ 
connection.Open(); 
// Do work here. 
} 

Connect to Oracle data source
The Oracle.NET Framework data provider USES the OracleConnection object to provide a connection to the Oracle data source.

using (OracleConnection connection = new OracleConnection(connectionString)) 
{ 
connection.Open(); 
// Do work here. 
} 
OracleConnection nwindConn = new OracleConnection("Data Source=MyOracleServer;Integrated Security=yes;"); 
nwindConn.Open(); 


Here is the connection example:

ACCESS

stringconStr=@"provider=microsoft.Jet.OleDb.4.0;datasource=d:\\accessData.mdb;uid=sa;pwd=dd"; 

SQL SERVER

stringconStr=@"Server=bwj;database=demo;uid=sa;pwd="; 

ORACLE

stringconStr=@"Provider=MSDAORA.1;Password=pwd;UserID=user_name;Data Source=link_str"

Related articles: