. Net Oracle connection

Source: Internet
Author: User

After the connection is successful, you can query it. It looks like WindowsProgramIt looks like a doscommand line tool. after entering the SQL statement, select "file/Run" to execute the SQL statement.

Configuration file (this file should be configured before use), because it is a lite version, no graphical tool configuration, all notepad

# Databasename =
# (Description =
# (Address_list =
# (Address = (Protocol = TCP) (host = 127.0.0.1) (Port = 1521 ))
#)
# (CONNECT_DATA =
# (SERVICE_NAME = servicename)
#)
#)

Modify the example configuration that has been commented out.

Myoracle =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 33.33.33.33) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = mysid)
)
)

Here, myoracle is a random name, and the data source of the connection string = myoracle; host, port Needless to say; SERVICE_NAME = mysid fill in the SID of the server database instance, the database is determined here.

After the configuration is complete, you can access Oracle in the program. The following example shows how to obtain the data of a table displayed on the page.

Using system. Data. oracleclient;

Oracleconnection con = new oracleconnection ("Data Source = myoracle; user id = xxx; Password = xxx ;");
Oraclecommand cmd = new oraclecommand ("select * from table", con );
Con. open ();
Oracledatareader DR = cmd. executereader (commandbehavior. closeconnection );
Gridview1.datasource = Dr;
Gridview1.databind ();
Dr. Close ();

-- Display all table information, similar to the show tables command of MySQL.
Select * From all_tables
-- Display the first few items, similar to SQL Server's select top
Select * from TB where rownum <= 5
-- From table name should be owner. table_name
Select * from Ms. mytable
-- The parameter symbols are different. For ORACLE: for SQL Server, for @ MySQL,?
Select * From tab where id =: myid

 

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.