Ado. net connection database string (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.
Using (sqlconnection connection = new sqlconnection (connectionstring ))
{
Connection. open ();
// Do work here.
}

Connect to the ole db data source (ACCESS)
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)).
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.
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.
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
String constr = @ "provider = Microsoft. Jet. oledb.4.0; datasource = D: \ accessdata. mdb; uid = sa; Pwd = dd ";

SQL Server
String constr = @ "Server = bwj; database = demo; uid = sa; Pwd = ";

Oracle
String constr = @ "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.