Oracle Connection Database

Source: Internet
Author: User
Tags oracleconnection

First, refer to the Oracle namespace

System.Data.OracleClient;

Second, connect the database code:

        Private DataTable SqlHelper (string commadtext)        {            try            {                //through configuration file, connection database                //string connectionstr = configurationsettings.appsettings["ConnectionString"]. ToString ();                OracleConnection conn = new OracleConnection (CONNECTIONSTR);                Direct string Connection Database                OracleConnection conn = new OracleConnection ("Data source=192.168.1.3; User id=epv7; PASSWORD=EPV7; Max Pool Size = + ");                Conn. Open ();                OracleDataAdapter SqlDA = new OracleDataAdapter (COMMADTEXT, conn);                DataSet ds = new DataSet ();                Sqlda.fill (DS);                Conn. Close ();                Return DS. Tables[0];            }            catch (Exception ex)            {                throw ex;            }        }

Third, through the configuration file connection database, configuration file content:

<configuration>  <appSettings>    <!--<add key= "DBType" value= "SQ"/>-->    <!-- <add key= "ConnectionString" value= "server=.;D Atabase=winstudent;uid=test;pwd=test "/>-->    <add key=" ConnectionString "value=" Data source= 192.168.1.113; User id=epv7; PASSWORD=EPV7; Max Pool Size = "/>  </appSettings></configuration>

If the following error occurs:

BadImageFormatException is raised when attempting to load the Oracle client library. This issue occurs if you are running in 64-bit mode with the 32-bit Oracle client component installed

Solution One:

Click the solution you want to run--right----properties, select Build---target platform, and change to x86

Solution Two:

Download the following DLL file and add a reference

Devart.data

Devart.Data.Oracle

The reference namespace is:

Using Devart.Data.Oracle;

Oracle Connection Database

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.