Method of Connecting C to Oracle Database

  • 2021-07-03 00:44:45
  • OfStack

This paper illustrates the method of connecting C # to Oracle database. Share it for your reference. The specific implementation method is as follows:


//1 Add a reference  System.data.oracleClient
//2 Set the connection string  data source Is the service name ( That is, on the client sqlplus The host string to be entered in the )
//3 The following usage and sqlserver Access  Usage 1 Straight 
string strConn = "data source=oamis;user=scott;password=tiger;";
OracleConnection conn = new OracleConnection(strConn);
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.CommandText = "select * from emp";
cmd.Connection = conn;
DataSet ds = new DataSet();
OracleDataAdapter ad = new OracleDataAdapter(cmd);
ad.Fill(ds);

I hope this article is helpful to everyone's C # programming.


Related articles: