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"