64-bit windows, using. net to connect to oracle 9 Summary

Source: Internet
Author: User
No:
1) use Ado. . Net, call system. data. oracleclient, and connect to it;
2) use odal, but use the local oraname;

Rows:

 

Public static string BuildConnStr ()
{
// Data Source = omc; User ID = spms; Password = spms;

// User id = hr; password = hr; data source = // sales-server: 1521/sales.us.acme.com
Try
{
Return string. Format ("user id = {1}; password = {2}; data source = {0 }",
ConfigurationManager. configurettings ["configurlename"],
ConfigurationManager. deleettings ["oracleUserName"],
ConfigurationManager. deleettings ["oraclePassword"]);

}
Catch (Exception ex)
{
MessageBox. Show (ex. Message );
}
Return string. Empty;
}

Public DataSet Execute ()
{
If (string. IsNullOrEmpty (_ ConnectionString) {throw (new Exception ("no incoming data connection string "));}

If (string. IsNullOrEmpty (_ CommandText) {throw (new Exception ("no incoming SQL statement "));}

If (! DSAFConnectionTest () {throw (new Exception ("failed to connect to the Database "));}

Try
{


OracleDataAdapter oracleDa = new OracleDataAdapter (_ CommandText, _ ConnectionString );

OracleDa. Fill (_ DSAFDataSet );
OracleDa. Dispose ();
}
Catch (OracleException DB2Ex)
{
MessageBox. Show (DB2Ex. Message );
Throw DB2Ex;
}
Catch (Exception ex)
{
MessageBox. Show (ex. Message );
Throw ex;
}

Return _ DSAFDataSet;
}

Private bool DSAFConnectionTest ()
{
Try
{
Conn = new OracleConnection (); Conn. ConnectionString = _ ConnectionString;
 
Conn. Open (); Conn. Close ();
}
Catch (Exception ex)
{
MessageBox. Show (_ ConnectionString );
MessageBox. Show (ex. Message );
Return (false );
}
 
Return (true );
}

Install odal
Download the ODAC (xcopy version) zip file to a directory for staging ODAC products.

Unzip ODAC (xcopy version) zip file to expand the contents.

The following directories will be created:

A) instantclient_11_2-Oracle Instant Client

B) ODP. NET20-Oracle Data Provider for. NET 2
C) ODP. NET4-Oracle Data Provider for. NET 4
D) ASP. NET-Oracle Providers for ASP. NET 2
E) ASP. NET4-Oracle Providers for ASP. NET 4
F) OLEDB-Oracle Provider for OLEDB
G) OraMTS-Oracle Services for MTS

The install. bat will also be extracted to the same location as the ODAC zip file, which is used to install and configure a specific product.

Execute install. bat to install and configure ODAC products.

To install all ODAC products, execute the following:

Install. bat all c: \ oracle odac

Each product can be also be installed and configured individually. As an example, executing the following will install only ODP. NET 2:

Install. bat odp. net2 c: \ oracle odac

Where "c: \ oracle", for example, is your installation directory and "odac" is the Oracle Home Name that is used for the registry keys. in this example, the registry entries for this install is created under

HKLM \ Sofware \ Oracle \ KEY_odac. note that ODP. NET registry entries are simply created under HKLM \ Software \ Oracle \ ODP. NET \, and not under HKLM \ Sofware \ Oracle \ KEY _. if multiple products are installed to the same

Destination directory, make sure that the Oracle Home Name that is specified as an argument to install. bat is the same for all those products.

By default, When install. bat is executed for a given product, the product and its dependencies will be installed and configured WITHOUT a check to see if there is a newer version of the product or its

Dependencies already installed.

Below is the product dependency information:

A) Oracle Data Provider for. NET 2 depends on
-Oracle Instant Client
B) Oracle Data Provider for. NET 4 depends on
-Oracle Instant Client
C) Oracle Providers for ASP. NET 2 depends on
-Oracle Instant Client
-Oracle Data Provider for. NET 2
D) Oracle Providers for ASP. NET 4 depends on
-Oracle Instant Client
-Oracle Data Provider for. NET 4
E) Oracle Provider for OLEDB depends on
-Oracle Instant Client
F) Oracle Services for MTS depends on
-Oracle Instant Client

To not have the products dependencies installed and configured, execute install. bat with 'false' as the fourth parameter.

For example, executing

Install. bat asp. net2 c: \ oracle odac false

Will only install and configure ASP. NET 2 and not install and configure ODP. NET 2 or instant client. if the last argument is not specified, the product and its dependencies will be installed and configured.

Add the install directory and install directory's bin subdirectory to the system PATH environment variable before any other Oracle directories. Otherwise, the products that are installed may not work

Properly as it will not be able to load the necessary DLLs. for example, if c: \ oracle was provided as the install directory, add c: \ oracle and c: \ oracle \ bin to the system PATH.
Add

Note that install. bat sets the value of the NLS_LANG registry key at HKLM \ Sofware \ Oracle \ KEY _ to AMERICAN_AMERICA.WE8MSWIN1252 by default. Please modify install. bat or change this value in the registry after

The install if necessary.
Try it first. You don't need to change it first. Wait until "can not access NLS" appears.

If OraMTS is installed, the OracleMTSRecoveryService is created with the LocalSystem account as the logon account. The credentials can be changed using the "services" administration tool. Please read

OraMTS readme.txt for details. Note that after the install or the configuration, the service will not be started, since it requires the install directory and its bin directory to be encoded in the system

PATH.
Don't worry about this

Application using components from ODAC can use ez connect to connect to Oracle without depending on tnsnames. ora. Otherwise, configure or copy over tnsnames. ora from another machine and set TNS_ADMIN or

ORACLE_HOME environment variable appropriately.
I am using the ez connect method, and I am not using tnsname. ora.

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.