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:
- CREATE TABLE TEST
- (
- AGREEMENT_ID CHAR(3) NOT NULL,
- AGREEMENT_CONTENT LONG NULL
- )
-
Insert data:
- protected void Button1_Click(object sender, EventArgs e)
- {
- OracleConnection conn = new OracleConnection(@"Password=XXXXXX;User ID=hk;Data Source=wealth;Persist Security Info=True");
- conn.Open();
- OracleCommand cmd = new OracleCommand("Select * From TEST", conn);
- string sql = "Insert Into TEST (AGREEMENT_ID, AGREEMENT_CONTENT) Values(:P_ID, :P_Value)";
- cmd.CommandText = sql;
- cmd.Parameters.Add("P_ID", this.TextBox2.Text);
- cmd.Parameters.Add("P_Value", this.TextBox1.Text);
- cmd.ExecuteNonQuery();
- conn.Close();
- }
Read data:
- protected void Button2_Click(object sender, EventArgs e)
- {
- OracleConnection conn = new OracleConnection(@"Password=XXXXXX;User ID=hk;Data Source=wealth;Persist Security Info=True");
- conn.Open();
- string sql = "Select * From TEST where AGREEMENT_ID = :P_ID";
- OracleDataAdapter da = new OracleDataAdapter(sql, conn);
- da.SelectCommand.Parameters.Add("P_ID", this.TextBox2.Text);
- DataSet ds = new DataSet();
- da.Fill(ds);
- this.TextBox1.Text = ds.Tables[0].Rows.Count.ToString();
- this.TextBox1.Text = ds.Tables[0].Rows[0]["AGREEMENT_CONTENT"].ToString();
- conn.Close();
- }
The above content is an introduction to the method for accessing the LONG field in Oracle. I hope you will get some benefits.