当前位置:我的异常网» 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
文章评论