ADO. Net instance code for oracle database operations

  • 2020-06-15 08:00:51
  • OfStack

The first thing to do is write the connection string

You can put it in web.config


<connectionStrings> 
    <add name="oracleson" connectionString="Data Source=dingsenorcl;Persist Security Info=True;User ID=ds;Password=ds;Unicode=True" providerName="System.Data.OracleClient"/> 
  </connectionStrings> 
<connectionStrings>
    <add name="oracleson" connectionString="Data Source=dingsenorcl;Persist Security Info=True;User ID=ds;Password=ds;Unicode=True" providerName="System.Data.OracleClient"/>
  </connectionStrings>

And then it's called in the background

string orclcon = ConfigurationManager.ConnectionStrings["oracleson"].ConnectionString; 
  string orclcon = ConfigurationManager.ConnectionStrings["oracleson"].ConnectionString;

Then create a new database connection object


OracleConnection conn = new OracleConnection(orclcon) 
OracleConnection conn = new OracleConnection(orclcon)

Create 1 OracleCommand object to manipulate the database

OracleCommand cmd = conn.CreateCommand() 
OracleCommand cmd = conn.CreateCommand() Open the connection 


conn. Open (); Just do it


cmd.CommandText = "insert into T_12(AAAA)values(:a)"; 
                    cmd.Parameters.AddWithValue(":a", TextBox1.Text);  // Parameters to replace oracle Database to use : sqlserver The database is @ 
                    cmd.ExecuteNonQuery(); 
cmd.CommandText = "insert into T_12(AAAA)values(:a)";
                    cmd.Parameters.AddWithValue(":a", TextBox1.Text);  // Parameters to replace oracle Database to use : sqlserver The database is @
                    cmd.ExecuteNonQuery();


Related articles: