I recommend using ODP.NET as it is free and is the official ADO.NET-compatible provider for connecting to Oracle. 1
To save your users from having to install Oracle Client separately, download Oracle Instant Client , open the following files ...
oci.dll Oracle.DataAccess.dll (the managed ODP.NET assembly itself) orannzsbb11.dll oraociei11.dll OraOps11w.dll
... and distribute them with your application.
Unfortunately, most of these DLLs are native (and 32-bit / 64-bit), so you cannot build the Any Processor platform ( 2 more).
The .NET code is identical to what you would use under the "thick" Oracle Client (and is very similar to any other ADO.NET provider there), except that you should probably consider using the "tnsnames.ora independent" line connections , for example:
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;
1 There are commercial alternatives and the old Microsoft provider, which is now outdated (and will not save you from installing external Oracle DLLs).
2 Either wait until the Fully Managed Oracle Provider or edit the project file (MSBuild XML) conditionally include 32-bit or 64-bit DLLs depending on the build platform, similar to this:
<Choose> <When Condition="'$(Platform)' == 'x64'"> <ItemGroup> <Reference Include="Oracle.DataAccess, processorArchitecture=x64"> <SpecificVersion>False</SpecificVersion> <HintPath>..\ThirdParty\ODP.NET\x64\Oracle.DataAccess.dll</HintPath> </Reference> <Content Include="..\ThirdParty\ODP.NET\x64\oci.dll"> <Link>oci.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="..\ThirdParty\ODP.NET\x64\orannzsbb11.dll"> <Link>orannzsbb11.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="..\ThirdParty\ODP.NET\x64\oraociei11.dll"> <Link>oraociei11.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="..\ThirdParty\ODP.NET\x64\OraOps11w.dll"> <Link>OraOps11w.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup> </When> <When Condition="'$(Platform)' == 'x86'"> <ItemGroup> <Reference Include="Oracle.DataAccess, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>..\ThirdParty\ODP.NET\x86\Oracle.DataAccess.dll</HintPath> </Reference> <Content Include="..\ThirdParty\ODP.NET\x86\oci.dll"> <Link>oci.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="..\ThirdParty\ODP.NET\x86\orannzsbb11.dll"> <Link>orannzsbb11.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="..\ThirdParty\ODP.NET\x86\oraociei11.dll"> <Link>oraociei11.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="..\ThirdParty\ODP.NET\x86\OraOps11w.dll"> <Link>OraOps11w.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup> </When> </Choose>
source share