If odp.net is installed on your machine and you are sure that the machine is. config also has the following nodules: (64-bit +. in the. NET 4.0 environment, machine. the Config may have four copies, corresponding. check the 4.0-bit version of net2.0/32/64)
<Dbproviderfactories> <Add name = "ORACLE data provider. net "invariant =" oracle. dataaccess. client "Description =" ORACLE data provider. net "type =" oracle. dataaccess. client. oracleclientfactory, Oracle. dataaccess, version = 2.111.7.20, culture = neutral, publickeytoken = 89b483f429c47342 "/> </dbproviderfactories>
In machine. config of 4.0, it is similar to the following:
<Dbproviderfactories> <Add name = "ORACLE data provider. net "invariant =" oracle. dataaccess. client "Description =" ORACLE data provider. net "type =" oracle. dataaccess. client. oracleclientfactory, Oracle. dataaccess, version = 4.112.2.0, culture = neutral, publickeytoken = 89b483f429c47342 "/> </dbproviderfactories>
If you happen to be using a 64-bit operating system (such as win2008 R2), the development tool is the most advanced vs.net 2010 SP1, Code It means that Oracle cannot be connected, and some strange errors have been reported: for example, "data provider cannot be found" and "oracle. dataaccess. the client cannot be loaded, "and so on. He is not doing anything at all, but he is shouting:" You have everything, you have everything!" Congratulations, most of you have encountered x64/x64 version problems. (It took me nearly a morning to figure out the problem.) After installing odp.net, it will be deployed in GAC by default. Program Set oracle. dataaccess. If you have installed the x86 version, the GAC version is x86. If you have installed the x64 version, the GAC version is amd64. Check whether the local GAC has an oracle. dataaccess assembly and check the version as follows: In the vs.net name line window, enter Gacutil.exe/L oracle. dataaccess If you see a result similar to the following:
D: \ app \ x86 \ Microsoft Visual Studio 10.0 \ Vc> gacutil.exe/L oracle. dataaccess
Microsoft (R). Net Global Assembly Cache utility. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
Oracle. dataaccess, version =
2.112.2.0
, Culture = neutral, publickeytoken = 89b483f429c47342, processorarchitecture =Amd64
Oracle. dataaccess, version =2.112.2.0, Culture = neutral, publickeytoken = 89b483f429c47342, processorarchitecture =X86
Oracle. dataaccess, version =4.112.2.0, Culture = neutral, publickeytoken = 89b483f429c47342, processorarchitecture =Amd64
Oracle. dataaccess, version =4.112.2.0, Culture = neutral, publickeytoken = 89b483f429c47342, processorarchitecture =X86
Number of items = 4 It indicates that four versions of Oracle are installed on your machine. dataaccess corresponds. NET 2.0 and. net 4.0 32-bit/64-bit and can be seen in the c: \ windows \ Assembly directory x86 and amd64-bit note: In the resource manager, only x86/amd64 versions of 2.112.2.0 can be seen, and no things of 4.112.2.0 can be seen (I don't know if it is my specific phenomenon, or another version may be elsewhere, but I didn't find it) if the version is missing, go to the Oracle official website to download it. The following uses 64-bit odp.net as an example:
1, After the download is complete, decompress it to a directory, such as E: \ Software \ oracle11g \ ODP. net, and then type the following command:
E: \ Software \ oracle11g \ ODP. Net \ x64> Install. bat all c: \ odp.net myhome (install all components)
The above command will automatically copy all files to c: \ odp.net
2, Go to c: \ odp.net and type the following command:
C: \ odp.net> Configure. bat all myhome (configure all component) The corresponding assembly will be automatically deployed to the GAC. Then, when adding a reference in vs2010, we should be able to see the two versions of Oracle. dataaccess.
Note: Only version 2.112.2.0 and 4.112.2.0 can be seen on this interface, which does not reflect the differences between x86 and x64. Paste the following sample code:
Using system; using Oracle. dataaccess. client; namespace test {class program {static void main (string [] ARGs) {// we recommend that you use this style of connection string, which does not depend on listener. configure string _ connstring = "Data Source = (description = (address_list = (address = (Protocol = TCP) (host = 127.0.0.1) (Port = 1521) in the ora file ))) (CONNECT_DATA = (Server = dedicated) (SERVICE_NAME = orcl); User ID = Scott; Password = tiger; "; using (oracleconnection conn = new oracleconnection (_ connstring )) {string SQL = "select * from EMP t where Mgr =: Mgr"; oraclecommand cmd = new oraclecommand (SQL, Conn); Conn. open (); cmd. parameters. add (New oracleparameter () {parametername = "Mgr", value = "7839"}); oracledatareader DR = cmd. executereader (); While (dr. read () {console. writeline ("empno: {0}, ename: {1}, Mgr: {2}", Dr ["empno"], Dr ["ename"], dr ["Mgr"]);} Dr. close ();} console. read ();}}}In a word: To Run 64-bit. net program, you must use 64-bit odp.net, to run 32-bit. net program, you must use a 32-bit odp.net, and machine. config must have the corresponding provider node. Finally, the ODP. net32-bit and 64-bit: 64-bit bytes are given.