在.net中读写ORACLE LOB 对象

本文介绍了一种在.NET环境中从Oracle数据库读取大型对象(LOB)数据的方法,并将其转换为字符串类型的实现细节。

转自 http://www.linkdns.com/ArticleView/20097/Article_10268.htm

在.net 中读写ORACLE ,LOB 对象

 ///
        /// 读取 ORACLE LOB 大数据列并转换为string类型
        ///
        ///
        public static string ReadLobField(string strSql, params OracleParameter[] cmdParms)
        {
            int actual = 0;
            StringBuilder sb = new StringBuilder();
            using (OracleDataReader reader = OracleHelper.ExecuteReader(strSql, cmdParms))
            {
                while (reader.Read())
                {
                    OracleLob myOracleClob = reader.GetOracleLob(0);
                    System.IO.StreamReader streamreader = new System.IO.StreamReader(myOracleClob, Encoding.Unicode);
                    char[] cbuffer = new char[100];
                    while ((actual = streamreader.Read(cbuffer, 0, cbuffer.Length)) > 0)
                    {
                        String tmpVal = new string(cbuffer, 0, actual);
                        sb.Append(tmpVal);
                    }
                }
            }
            return sb.ToString();
        }

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值