Four ways to connect to a database in C #
Before you connect to the following database, install the Oracle Client locally, and the version of this test System.Data is: 2.0.0.0.
On the installation of Oracle client please note that if the OS is 3-bit Please install the Oracle client-bit , but the OS is-bitand needs to be installed according to the actual situation, If your app is running according to-bit , you need to install the-bit client, if it is 64-bit run, install 64-bit client, not the OS is-bit , The 64-bit Oracle client will be installed.
This test will be tested at the same time on the-bit and-bit , with a-bit oracle10g.
1.ODBC
1.1 first needs to be in Control Panel, management tools, data Source (ODBC).
1 . 2 using System.Data.Odbc;
1.3 Connection Database
OdbcConnection conn = new OdbcConnection (dsn=xxx; Uid=XXX; pwd=XXX;);
Conn. Open ();
Conn. Close ();
-bit and-bit are OK.
2.OleDb
2.1 OLE DB connection driver msdaora and OraOLEDB.Oracle, respectively, by Microsoft and oracle. use OraOLEDB.Oracle drive Oracle Data provider for OLE DB. Both on 32-bit machines, on 64-bit machines, using "msdaora" will appear " The "msdaora.1" provider "problem is not registered on the local computer, OraOLEDB.Oracle everything is fine.
2.2 Connection Database
Using System.Data.OleDb;
OleDbConnection conn = new OleDbConnection ("Provider=MSDAORA.1; User id=xxx;password=xxx;data source=XXX; Persist Security info=false "); Provider need to change according to the actual situation
Conn. Open ();
Conn. Close ();
3.OracleClient
3.1 //using System.Data.OracleClient;
3.2 connecting to a database
OracleConnection conn = new OracleConnection ("Data source=xxx;user=xxx;password=XXX;");
Conn. Open ();
Conn. Close ();
-bit and 64-bit are OK.
4.OracleDataAccess
4.1//using Oracle.DataAccess.Client need to install Oracle Data providerfor. NET Framework 2
4.2 Connection Database
Oracle.DataAccess.Client.OracleConnection conn = new Oracle.DataAccess.Client.OracleConnection ("Data source=yellow; User id=knemes; Password=oracle ");
Conn. Open ();
Conn. Close ();
-bit and 64-bit are OK, but you need to pay attention to your version
Four ways to connect to a database in C # (GO)