1 "Download on Oracle network: odp.net
2 Select Download according to your Oracle data 32bit/64bit.
3 "Follow the prompts to configure the Tnsnames.ora file.
# alias = # (DESCRIPTION = # (ADDRESS = (PROTOCOL = TCP) (HOST =localhost) (PORT = 1521)) # (Connect_data = # (SERVER = DEDI cated) # (service_name = ORCL) #) |
Alias: You can define it casually, such as: ORL; port: The port number when you install Oracle data yourself. SERVICE_NAME: The database instance name created by the installation of Oracle data, such as: ORCL. |
4 "Find the downloaded odp.net (Oracle data Providepor for VSXXXX), typically installed in C:\Program Files (x86) \oracle Developer Tools for VS2015, find the ODP. Net Folder and the Odt folder, find OraVSProvCfg.exe in the inside to register.
5 "After the registration, you can carry out a simple application.
Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; The using oracle.dataaccess.client;//references Dllnamespace consoleapplication2{class program {static void Main (string [] args) {string constr = "User Id=leo; Password=m123;data SOURCE=ORCL "; OracleConnection con = new OracleConnection (CONSTR); Con. Open (); Display Version number Console.WriteLine ("Connected to Oracle" + con. ServerVersion); OracleCommand CMMD = new OracleCommand ("SELECT * from Leo_person", con); OracleDataAdapter OA = new OracleDataAdapter (CMMD); System.Data.DataSet ds = new System.Data.DataSet (); Oa. Fill (ds, "person"); foreach (System.Data.DataRow row in DS. Tables[0]. Rows) {int count = 0; foreach (System.Data.DataColumn column in DS. Tables[0]. Columns) {CONSOLE.WRite (column. ColumnName + ":" + row[column] + "\ t"); count++; } if (count = = 3) {Console.Write ("\ n"); }}//Close and Dispose oracleconnection con. Close (); Con. Dispose (); Console.read ();
What settings do I need to VS2015 to operate Oracle data?