vb读取oracle中clob数据类型,oracle的CLOB字段,如何用VB6来读写

当前位置:我的异常网» VB » oracle的CLOB字段,如何用VB6来读写

oracle的CLOB字段,如何用VB6来读写

www.myexceptions.net  网友分享于:2013-01-11  浏览:273次

oracle的CLOB字段,怎么用VB6来读写?

找到过一个关于BLOB字段的读写模块,用这个来存取图片等文件都成功了,但是.TXT用这个来处理,想存进CLOB字段会变成乱码,有人能找出其中的问题所在吗?

Option   Explicit

Public   rn   As   ADODB.Connection

Public   Function   CreateDataSource(DataSource   As   String,   UserID   As   String,   Password   As   String)   As   Boolean

On   Error   GoTo   DbConErr:

Set   rn   =   New   ADODB.Connection

With   rn

.ConnectionString   =   "Provider=OraOLEDB.Oracle.1;   password=TEST   ;User   ID   =   TEST;Data   Source=DEV;Locale   Identifier=2052 "

.Open

End   With

CreateDataSource   =   True

Exit   Function

DbConErr:

CreateDataSource   =   False

End   Function

Sub   BlobToFile(fld   As   ADODB.Field,   filename   As   String,   Optional   ChunkSize   As   Long   =   8192)

Dim   fnum   As   Integer,   bytesleft   As   Long,   bytes   As   Long

Dim   tmp()   As   Byte

If   (fld.Attributes   And   adFldLong)   =   0   Then

Err.Raise   1001,   ,   "field   doesn 't   support   the   GetChunk   method. "

End   If

If   Dir$(filename)   <>   " "   Then   Kill   filename

fnum   =   FreeFile

Open   filename   For   Binary   As   fnum

bytesleft   =   fld.ActualSize

Do   While   bytesleft

bytes   =   bytesleft

If   bytes   >   ChunkSize   Then   bytes   =   ChunkSize

tmp   =   fld.GetChunk(bytes)

Put   #fnum,   ,   tmp

bytesleft   =   bytesleft   -   bytes

Loop

Close   #fnum

End   Sub

Sub   FileToBlob(fld   As   ADODB.Field,   filename   As   String,   Optional   ChunkSize   As   Long   =   8192)

Dim   fnum   As   Integer,   bytesleft   As   Long,   bytes   As   Long

Dim   tmp()   As   Byte

If   (fld.Attributes   And   adFldLong)   =   0   Then

Err.Raise   1001,   ,   "field   doesn 't   support   the   GetChunk   method. "

End   If

If   Dir$(filename)   =   " "   Then   Err.Raise   53,   ,   "File   not   found "

fnum   =   FreeFile

Open   filename   For   Binary   As   fnum

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值