System.Data.OracleClient Microsoft-provided connection library, but it is outdated, not recommended
Two. Oracle.DataAccess.Client (odp.net) Oracle provides a database access class library.
Three. Oracle.ManagedDataAccess.dll (Odp.net Managed) is also provided by Oracle.
Scenario 3 is recommended, but if you use manageddataaccess, you must add a reference to the assembly "Netstandard", which is the framework 4.6 and above.
So I am using the. NET Framework 4.5 of the project is not used, the adoption of the second approach, scenario two is to distinguish between the x86/x64 version.
1. Go to the official website to download the required DLL files.
Http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html
Download the corresponding VS version of the DLL file, if the VS version is too low, download the oldest DLL file, the author downloaded the oldest: Odac 11.2 Release 5
Place these DLL files under the bin directory where the project is running, and run the file in the same directory.
Database Connection statement:
< connectionStrings > < name= "oracleconnstring" connectionString= "Data source= (description= ( Address= (PROTOCOL=TCP) (host=192.168.1.161) (port=1521)) (Connect_data= (sid=myoracle))); Persist Security info=true; User Id=system; password=sky312; " /> </ connectionStrings >
C # calls
Private ReadOnly stringConnStr = configurationmanager.connectionstrings["oracleconnstring"]. ConnectionString;stringsql ="select * from \ "Userinfo\""; OracleConnection Connection=NewOracleConnection (CONNSTR); connection. Open (); OracleCommand command=Neworaclecommand (SQL, connection);D atatable table=NULL;Try{OracleDataAdapter Adapter=NewOracleDataAdapter (); Adapter. SelectCommand=command; Table=NewDataTable (); Adapter. Fill (table);}Catch{ Throw;}finally{command. Dispose (); Connection. Close (); Connection. Dispose ();}
Datagridview1.datasource =Table;
Inquire
oracle-c# Connection Database