Solution description for Oracle to access LONG Fields

Source: Internet
Author: User
Tags oracleconnection

The following articles mainly describe how to access the LONG field in Oracle. We all know that this data type can be used for large text types that access more than 4000 bytes in Oracle, the read/write method in C # is as follows: note that System must be referenced. data. oracleClient.

Then add the namespace: using System. Data. OracleClient

Oracle Database creation script:

 
 
  1. CREATE TABLE TEST  
  2. (  
  3. AGREEMENT_ID CHAR(3) NOT NULL,  
  4. AGREEMENT_CONTENT LONG NULL  
  5. )  
  6.  

Insert data:

 
 
  1. protected void Button1_Click(object sender, EventArgs e)  
  2. {  
  3. OracleConnection conn = new OracleConnection(@"Password=XXXXXX;User ID=hk;Data Source=wealth;Persist Security Info=True");  
  4. conn.Open();  
  5. OracleCommand cmd = new OracleCommand("Select * From TEST", conn);  
  6. string sql = "Insert Into TEST (AGREEMENT_ID, AGREEMENT_CONTENT) Values(:P_ID, :P_Value)";  
  7. cmd.CommandText = sql;  
  8. cmd.Parameters.Add("P_ID", this.TextBox2.Text);  
  9. cmd.Parameters.Add("P_Value", this.TextBox1.Text);  
  10. cmd.ExecuteNonQuery();  
  11. conn.Close();  
  12. }  

Read data:

 
 
  1. protected void Button2_Click(object sender, EventArgs e)  
  2. {  
  3. OracleConnection conn = new OracleConnection(@"Password=XXXXXX;User ID=hk;Data Source=wealth;Persist Security Info=True");  
  4. conn.Open();  
  5. string sql = "Select * From TEST where AGREEMENT_ID = :P_ID";  
  6. OracleDataAdapter da = new OracleDataAdapter(sql, conn);  
  7. da.SelectCommand.Parameters.Add("P_ID", this.TextBox2.Text);  
  8. DataSet ds = new DataSet();  
  9. da.Fill(ds);  
  10. this.TextBox1.Text = ds.Tables[0].Rows.Count.ToString();  
  11. this.TextBox1.Text = ds.Tables[0].Rows[0]["AGREEMENT_CONTENT"].ToString();  
  12. conn.Close();  
  13. }  

The above content is an introduction to the method for accessing the LONG field in Oracle. I hope you will get some benefits.
 

Related Article

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.