ADO. NET database connection string Summary (Oracle, SqlServer, Access, ODBC)

Source: Internet
Author: User
Tags oracleconnection

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.
Copy codeThe Code is as follows:
Using (SqlConnection connection = new SqlConnection (connectionString ))
{
Connection. Open ();
// Do work here.
}

Connect to the ole db Data Source
Ole db. NET Framework data providers provide connections to data sources exposed by ole db through OleDbConnection objects and to Microsoft SQL Server 6.x or earlier versions (through the ole db provider for SQL Server (SQLOLEDB)).
Copy codeThe Code is as follows:
Using (OleDbConnection connection = new OleDbConnection (connectionString ))
{
Connection. Open ();
// Do work here.
}


Connect to the ODBC Data Source
The ODBC. NET Framework data provider uses the OdbcConnection object to provide connections to data sources exposed by ODBC.
Copy codeThe Code is as follows:
Using (OdbcConnection connection = new OdbcConnection (connectionString ))
{
Connection. Open ();
// Do work here.
}

Connect to the Oracle Data Source
The Oracle. NET Framework data provider uses the OracleConnection object to provide a connection to the Oracle data source.
Copy codeThe Code is as follows:
Using (OracleConnection connection = new OracleConnection (connectionString ))
{
Connection. Open ();
// Do work here.
}
OracleConnection nwindConn = new OracleConnection ("Data Source = MyOracleServer; Integrated Security = yes ;");
NwindConn. Open ();


The following are the connection instances:

ACCESS
Copy codeThe Code is as follows:
StringconStr = @ "provider = microsoft. Jet. OleDb.4.0; datasource = d: \ accessData. mdb; uid = sa; pwd = dd ";

SQL SERVER
Copy codeThe Code is as follows:
StringconStr = @ "Server = bwj; database = demo; uid = sa; pwd = ";

ORACLE
Copy codeThe Code is as follows:
StringconStr = @ "Provider = MSDAORA.1; Password = pwd; UserID = user_name; Data Source = link_str"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.