C#中如何操作Oracle里面的Clob字段,急

ar7_top 2003-10-15 11:14:29
假设现在有一个数据表 T_Test
有三个字段,ID(char11,notnull),Name(varchar200),Note(Clob)
求对该表读,新增,修改,删除 四种操作的代码,谢谢了

很急很急
...全文
166 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
ar7_top 2003-10-16
  • 打赏
  • 举报
回复
尝试中,这么多内容,应该可以吧
我先给分了,呵呵呵
bbwolfcool 2003-10-15
  • 打赏
  • 举报
回复
多谢多谢,一起顶
qiujinwen 2003-10-15
  • 打赏
  • 举报
回复
你是用什么操作.oledb操作吗?...我现在能写能读。。不过是是用oracleclient去操作的。。。中间要用存储过程。用oracle中的DBMS_Lob包中的DBMS_Lob.write和DBMS_Lob.read来进行写和读的操作.删除的话就delete记录就可以了
ar7_top 2003-10-15
  • 打赏
  • 举报
回复
多谢多谢,一起顶
qiujinwen 2003-10-15
  • 打赏
  • 举报
回复
帮你顶。。我也正想问这问题....
angelior 2003-10-15
  • 打赏
  • 举报
回复
可不可以!
孟子E章 2003-10-15
  • 打赏
  • 举报
回复
http://www.datadirect-technologies.com/download/docs/dotnet/dotnetref/dotnetOra.html


http://otn.oracle.com/sample_code/tech/windows/odpnet/howto/rlock/index.html
孟子E章 2003-10-15
  • 打赏
  • 举报
回复
using System;
using System.Text;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;

namespace ConsoleApplication23
{
/// <summary>
/// Summary description for Class1.
/// </summary>

class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>

[STAThread]

static void Main(string[] args)
{

// Step 1
// Establish connection using ODP.NET
// NOTE: Modify User Id, Password, Data Source as per your database setup
string connectStr = "User Id=scott;Password=tiger;Data Source=orcl9i";

OracleConnection connection = new OracleConnection(connectStr);
connection.Open();
Console.WriteLine("Connected to database");
Console.WriteLine(" ");


// Step 2
// Declare Oracle objects
OracleTransaction txn;
OracleCommand cmd = new OracleCommand("",connection);
OracleDataReader reader;
OracleClob clob;

try
{
// Step 3
// Start a transaction
txn = connection.BeginTransaction();


// Step 4
// Lock the result set using the "FOR UPDATE" clause
cmd.CommandText = "SELECT story FROM multimedia_tab FOR UPDATE";
reader = cmd.ExecuteReader();


// Step 5
// Read data from OracleDataReader using a proper typed accessor
// to an Oracle LOB object

reader.Read();
clob = reader.GetOracleClob(0);
Console.WriteLine("Old Data: {0}", clob.Value);
Console.WriteLine(" ");


// Step 6
// Modify the CLOB column of the row
string ending = " The end.";

// Append CLOB data to the current OracleCLOB instance
clob.Append(ending.ToCharArray(), 0, ending.Length);

// Release the lock
txn.Commit();
Console.Write("Updated to new data:");
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e.Message);

}

try
{
// Step 7
// Fetch the modified data from the database
// Lock the complete resultset using the "FOR UPDATE" clause
cmd.CommandText = "SELECT story FROM multimedia_tab FOR UPDATE";
reader = cmd.ExecuteReader();
reader.Read();
clob = reader.GetOracleClob(0);
Console.WriteLine( clob.Value);
Console.WriteLine(" ");

// Step 8
// Reset data with the old value
// Start an Oracle transaction
txn = connection.BeginTransaction();

// Clear the contents of the current instance of OracleCLOB object
clob.Erase();

// Re-write a string to the old value
StringBuilder blr1 = new StringBuilder();
blr1.Append("'This is a long story. Once upon a time ...',");
String oldData = blr1.ToString();


// Step 9
// Write the byte array into the OracleCLOB object
clob.Write(oldData.ToCharArray(),0, oldData.Length);



// Update the data and release the lock
txn.Commit();


Console.WriteLine("Old data again: {0}", clob.Value);

}

catch (Exception e)
{
Console.WriteLine("Error: {0}", e.Message);
}

finally
{

// Dispose OracleCommand object
cmd.Dispose();

// Close and Dispose OracleConnection object
connection.Close();
connection.Dispose();
}
}
}

}


herofyf 2003-10-15
  • 打赏
  • 举报
回复
学习
孟子E章 2003-10-15
  • 打赏
  • 举报
回复
http://otn.oracle.com/sample_code/tech/windows/odpnet/howto/rlock/ResultsetSrcC.html
孟子E章 2003-10-15
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoracleclientoraclelobclasstopic.asp

http://www.codeproject.com/aspnet/upsanddowns.asp?print=true
wangj2001 2003-10-15
  • 打赏
  • 举报
回复
你的邮件,我给你源码,我的Eamil:wj_wj_2001@163.com
给我来邮件即可,我用的不是oledb,而是oracel在C#中的访问包
ar7_top 2003-10-15
  • 打赏
  • 举报
回复
帮帮忙啊,要的很急呢
ar7_top 2003-10-15
  • 打赏
  • 举报
回复
我想要操作的源代码
本课程详细讲解了以下内容:    1.jsp环境搭建及入门、虚拟路径和虚拟主机、JSP执行流程    2.使用Eclipse快速开发JSP、编码问题、JSP页面元素以及request对象、使用request对象实现注册示例    3.请求方式的编码问题、response、请求转发和重定向、cookie、session执行机制、session共享问题     4.session与cookie问题及application、cookie补充说明及四种范围对象作用域     5.JDBC原理及使用Statement访问数据库、使用JDBC切换数据库以及PreparedStatement的使用、Statement与PreparedStatement的区别     6.JDBC调用存储过程和存储函数、JDBC处理大文本CLOB及二进制BLOB类型数据     7.JSP访问数据库、JavaBean(封装数据和封装业务逻辑)     8.MVC模式与Servlet执行流程、Servlet25与Servlet30的使用、ServletAPI详解与源码分析     9.MVC案例、三层架构详解、乱码问题以及三层代码流程解析、完善Service和Dao、完善View、优化用户体验、优化三层(加入接口和DBUtil)    1 0.Web调试及bug修复、分页SQL(Oracle、MySQL、SQLSERVER)     11.分页业务逻辑层和数据访问层Service、Dao、分页表示层Jsp、Servlet     12.文件上传及注意问题、控制文件上传类型和大小、下载、各浏览器下载乱码问题     13.EL表达式语法、点操作符和括号操作符、EL运算、隐式对象、JSTL基础及set、out、remove     14.过滤器、过滤器通配符、过滤器链、监听器     15.session绑定解绑、钝化活化     16.以及Ajax的各种应用     17. Idea环境下的Java Web开发

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧