VS2010 Connecting to Oracle Database (. NET 2.0 supported)

Source: Internet
Author: User

Recently saw a lot of links to Oracle database blog, after I measured, the. NET environment to connect to the Oracle database is divided into the following steps:

1. Connecting an Oracle database requires downloading a Oracle.DataAccess.dll file. The address is here Http://pan.baidu.com/s/1ctAsY

2. Open VS, create a new project. Then the project right--adds the reference.

Then browse to find the downloaded Oracle.DataAccess.dll added in.

3. Add using Oracle.DataAccess.Client; this reference.

4. Code:

        Private voidBtnselect_click (Objectsender, EventArgs e) {            stringconnectionString; stringqueryString; ConnectionString="Data source=oracle; User Id=zjhis; Password=zjhis";//Database connection StringQueryString =string. Format ("SELECT * from mz_mzsfk1 where SFSB = {0}", tbxSfsb.Text.ToString ());//SQL statementsOracleDataAdapter adapter =NewOracleDataAdapter (querystring,connectionstring);//EXECUTE statement, execution result in adapterDataSet ds=NewDataSet (); Adapter. Fill (DS,"MZ_MZSFK1");//populate the DataSet with the execution resultsDataTable dt = ds. tables["MZ_MZSFK1"]; Tbxsfsb.text= dt. rows[0]["SFSB"].            ToString (); Tbxname.text= dt. rows[0]["BRXM"].            ToString (); Tbxxj.text= dt. rows[0]["XJ"].         ToString (); }

Note that I am connected to the data on the server, but do not specify the server IP address when filling in data source (if you write an IP address, such as 192.168.1.4/oracle instead of error). this may be related to the installation of oracle-oraclient10g_home2, but without testing.

5. If you are under the framework of. NET 2.0, you need to delete the using System.Data.linq; This reference.

VS2010 Connecting to Oracle Database (. NET 2.0 supported)

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.