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.