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

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

很急很急
...全文
157 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
  • 打赏
  • 举报
回复
我想要操作的源代码

110,533

社区成员

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

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

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