Oracle.ManagedDataAccess.dll

Source: Internet
Author: User
Tags oracleconnection

In the first contact with C # when the company is using Oracle database, then C # How to connect Oracle database is the first to grasp the knowledge point. There was no odp.net at the time, but Visual Studio integrated the call to the Oralce database, which is in this, although Visual Studio is now using this as a reminder of the outdated, but it was very useful at the time.

Why is this assembly still available in Visual Studio now, with Odp.net, just take out Oracle.ManagedDataAccess.dll to focus on this article?

1. In Visual Studio, reminders are outdated because Microsoft and Oracle have a competitive relationship with the database and from. NET update to see that the Assembly has not been updated, for the database has been updated and called the Assembly has not been updated dare to use it? Another reason I think is very important is to use this assembly, to get rid of every client running the program to install the Oracle client's fact, imagine, if the number of users is huge, install the client's workload is quite large, very expensive resources;

2, Oracle later out of the odp.net, all kinds of information and the official network said need to install odp.net, and then reference Oracle.ManagedDataAccess.dll, he and Visual Studio in the biggest difference between the assembly is updated with the database, is the official Oracle driver;

3, in fact, after testing, the ODP. NET installation is completely unnecessary, Download a Oracle.ManagedDataAccess.dll directly online, as follows, use this method to reduce the installation of odp.net, ignoring the number of operating system, the most important thing is to reduce the installation of Oracle client;

So where do I download the Oracle.ManagedDataAccess.dll? How do I know if Oracle.ManagedDataAccess.dll has an update? This time the most powerful development tool in the universe comes up!

The installation can be done by the code, and if there are updates can be seen at any time. And there is not much difference between programming and previous use of the System.Data.OracleClient assembly, basically making a few changes to the code that previously used the System.Data.OracleClient assembly.

1. Use the connection string instead of the Oracle client's service name;

2. Changes in several namespaces;

The following is an encapsulation of common database operations

Using system;using system.collections.generic;using system.linq;using system.text;using System.Configuration;using Oracle.manageddataaccess.client;using system.data;using system.io;using system.collections;using System.diagnostics;using oracle.manageddataaccess.types;namespace oracledemo{public class OracleHelper {pri vate static string connstr = "User id=admin; Password=123;data source= (description= (address_list= (address=) (PROTOCOL=TCP) (host=192.168.0.1)) (        Connect_data= (service_name=test))) ";             #region Execute SQL statement that returns the number of rows affected public static int ExecuteNonQuery (String sql, params oracleparameter[] parameters) { using (OracleConnection conn = new OracleConnection (CONNSTR)) {Conn.                Open (); using (oraclecommand cmd = conn.                    CreateCommand ()) {cmd.commandtext = SQL; Cmd.                    Parameters.addrange (Parameters); return CMD.       ExecuteNonQuery ();         }}} #endregion #region execute the SQL statement and return to the DataTable; public static DataTable executedatatable (String sql, params oracleparameter[] parameters) {using (OracleConnection C Onn = new OracleConnection (CONNSTR)) {Conn.                Open (); using (oraclecommand cmd = conn.                    CreateCommand ()) {cmd.commandtext = SQL; Cmd.                    Parameters.addrange (Parameters);                    OracleDataAdapter adapter = new OracleDataAdapter (cmd);                    DataTable datatable = new DataTable (); Adapter.                    Fill (DataTable);                return DataTable; }}} #endregion}}

The following code is called part

                String sqlString = "Select A.col1,a.col2 from Test a Where a.id=:id";                DataTable dt = oraclehelper.executedatatable (Sqlstring,new oracleparameter (": id", 1));

After the completion of the program, the directory is probably as follows:

This time, copy the Debug folder to the target client computer to run directly (provided that the target client computer has the. NET Framework), completely out of the installation of the Oracle client.

Oracle.ManagedDataAccess.dll

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.