Oracle Database Connection and Oracle Database Connection

Source: Internet
Author: User
Tags oracleconnection

Oracle Database Connection and Oracle Database Connection

Modeled http://blog.csdn.net/makenothing/article/details/17080069

1. Create an Oracle connection. Add a database connection in VS2010.

Obtain the connection string

Data Source = server1; Persist Security Info = True; User ID = s227; Password = ×××; Unicode = True ××× your Password

2. Create a VS2010 C # console Program

This is the convenience of the sample program console.

Add the System. Data. OracleClient reference to the reference (this reference is available under Framwork 4.0). For details, refer to the program with errors in the url I started.

Then using System. Data. OracleClient

3. Start the sample program

Using System; using System. collections. generic; using System. linq; using System. text; using System. data. oracleClient; namespace ConsoleApplication1 {class Program {static void Main (string [] args) {string connString = "Data Source = server1; Persist Security Info = True; User ID = s227; password = 123; Unicode = True "; string queryString =" SELECT * from product "; OracleConnection conn = new OracleConnection (connString); conn. open (); OracleCommand command = new OracleCommand (queryString, conn); OracleDataReader reader = command. executeReader (); reader. read (); Console. writeLine ("1" + reader ["MAKER"] + "2" + reader ["MODEL"] + "3" + reader ["TYPE"]); reader. close (); conn. close ();/** // learned code block string connectionString; string queryString; connectionString = "Data Source = 202.200.136.125/orcl; User ID = openlab; PassWord = open123 "; queryString = "SELECT * FROM T_USER"; OracleConnection myConnection = new OracleConnection (connectionString); OracleCommand myConnection command = myConnection. createCommand (); mydomaincommand. commandText = queryString; myConnection. open (); OracleDataReader myDataReader = mydomaincommand. executeReader (); myDataReader. read (); Console. writeLine ("email:" + myDataReader ["EMAIL"]); myDataReader. close (); myConnection. close ();*/}}}


Output 1 A 2 1001 3 PC

This output corresponds to your queryString

That is, the query statement is related.

 

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.