Ado. net
Connect to SQL Server
SQL Server. NET Framework data provisionProgramSupports connection string format similar to ole db (ADO) connection string format.
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)).
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
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"