Ado. NET instance code for Oracle database operations-Practical tips

Source: Internet
Author: User

To write the connection string first

It can be written in web.config.

Copy Code code as follows:

<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 call back in the background
Copy Code code as follows:

String Orclcon = configurationmanager.connectionstrings["Oracleson"]. ConnectionString;

String Orclcon = configurationmanager.connectionstrings["Oracleson"]. ConnectionString;


Then you want to create a new database connection object

Copy Code code as follows:

OracleConnection conn = new OracleConnection (Orclcon)

OracleConnection conn = new OracleConnection (Orclcon)


Create a OracleCommand object to manipulate the database
Copy Code code as follows:

OracleCommand cmd = conn. CreateCommand ()

OracleCommand cmd = conn. CreateCommand () Open connection


Conn. Open (), action on the line

Copy Code code as follows:

Cmd.commandtext = "INSERT into T_12 (AAAA) VALUES (: a)";
Cmd.  Parameters.addwithvalue (": A", TextBox1.Text); Parameter replaces Oracle database with: SQL Server database is @
Cmd. ExecuteNonQuery ();

Cmd.commandtext = "INSERT into T_12 (AAAA) VALUES (: a)";
Cmd.  Parameters.addwithvalue (": A", TextBox1.Text); Parameter replaces Oracle database with: SQL Server database is @
Cmd. ExecuteNonQuery ();

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.