Oracle:ODP.NET Managed Small test sledgehammer (turn)

Source: Internet
Author: User
Tags oracleconnection oracle developer

"Odp.net Managed" has been released for some time, recently there is a new project, want to try to use, refer to the Garden article: ". NET Oracle Developer Gospel--odp.net Managed officially launched" to the Oracle website download ODP.NET_Managed121010.zip about 1.9M, after extracting the directory structure as follows:

The core DLL, is the common directory of Oracle.ManagedDataAccess.dll, unlike the previous version of Odp.net, this time finally do not have to distinguish x86/x64 version, whether it is 32-bit or 64-bit, are the same DLL.

As for the two directories of Manged/x64, managed/x86, which are used to register assemblies with the GAC of. NET x86 or. NET x64, When the associated Configure.bat is run, the Oracle.ManagedDataAccess.dll in common is automatically placed in the GAC, which automatically finds the relevant namespaces in the GAC when you add a reference to VS

On a machine running Configure.bat, the application's Bin directory does not have to include Oracle.ManagedDataAccess.dll, and it will run normally.

Note: Configure.bat This step is optional and when you add a reference, you can completely copy the DLL to the bin directory by directly browsing the Oracle.ManagedDataAccess.dll location.

The following is the most basic code of use:

1UsingSystem;2UsingSystem.Data;3UsingOracle.ManagedDataAccess.Client;45NamespaceOdp.net6{7ClassProgram8{9Staticvoid Main (String[] args)10{OracleConnection conn =Null;12Try13{conn =Openconn ();15var cmd =Conn. CreateCommand ();Cmd.commandtext ="SELECT * FROM S_awb_master where rownum=1";Cmd.commandtype =CommandType.Text;18var reader =Cmd. ExecuteReader ();19While(Reader. Read ())20{Console.WriteLine (String. Format ("Awbpre:{0},awbno:{1}", reader["Awbpre"], reader["Awbno"]));22}23}24Catch(Exception ex)25{26Console.WriteLine (ex. Message);27}28Finally29{30CLOSECONN (conn);31}32Console.read ();33}343536StaticOracleConnection Openconn ()37{OracleConnection conn =NewOracleConnection ();Conn. ConnectionString ="Data source= (description= (address= (protocol=tcp) (host=***.***.***.***) (port=1521)) (Connect_data= (SERVICE_NAME=* **))); Persist Security info=true; User id=***; password=***;";40Conn. Open ();41ReturnConn42}4344StaticvoidCloseconn (OracleConnection conn)45{46if (conn = =NULL) {Return; }47Try48{49IF (Conn. State! =connectionstate.closed)50{51Conn. Close ();52}53}54 catch (Exception e)  {56 Span style= "color: #000000;" > Console.WriteLine (e.message); 57 }58 finally59  {60  Conn. Dispose (); 61 }62 }63 }64}   

Finally attach dll download: http://files.cnblogs.com/yjmyzz/Oracle.ManagedDataAccess.zip

Oracle:ODP.NET Managed Small test sledgehammer (turn)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.