Ado.net Connection Database String Summary (Oracle, SQL Server, Access, ODBC) _ Basic Application

Source: Internet
Author: User
Tags microsoft sql server odbc ole oracleconnection string format
ado.net

Connecting to SQL Server
The SQL Server. NET Framework Data Provider supports a connection string format similar to the OLE DB (ADO) connection string format.
Copy Code code as follows:

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

Connecting to an OLE DB data source
The OLE DB. NET Framework Data Provider provides a connection to a data source exposed by using OLE DB and with Microsoft SQL Server 6.x or earlier, through the OleDbConnection object, for SQL Server OLE DB Provider (SQLOLEDB)) connection.
Copy Code code as follows:

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


Connecting to an ODBC data source
The ODBC. NET Framework Data Provider provides a connection to a data source exposed by using ODBC through the OdbcConnection object.
Copy Code code as follows:

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

Connecting to an Oracle data source
The Oracle. NET Framework Data Provider uses the OracleConnection object to provide a connection to an Oracle data source.
Copy Code code 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 connection instances:

ACCESS
Copy Code code as follows:

stringconstr=@ "Provider=microsoft. Jet.oledb.4.0;datasource=d:\\accessdata.mdb;uid=sa;pwd=dd ";

SQL SERVER
Copy Code code as follows:

stringconstr=@ "server=bwj;database=demo;uid=sa;pwd=";

ORACLE
Copy Code code as follows:

stringconstr=@ "Provider=MSDAORA.1; Password=pwd; Userid=user_name;data Source=link_str "

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.