【发布时间】:2012-06-13 04:47:53
【问题描述】:
用 VB6 编写的应用程序。 DB 是 Pervasive v9.5。
目前有效:
Public Sub Save()
if rs.State = adStateOpen Then
rs.AddNew
SetFields rs
rs.Update
End If
end sub
Public Sub SetFields(rs as ADODB.Recordset)
rs!Name = strName
StrToField strReport rs!Report
StrToField strResponse rs!Response
end sub
Public Sub StrToField(ByVal str As String, fld As ADODB.Field)
Dim Data As String
Dim StrSize As Long, CharsRead As Long
' for field of LONVARCHAR type only
If fld.Type = adLongVarChar Then
StrSize = Len(str)
Do While StrSize <> CharsRead
If StrSize - CharsRead < BLOCK_SIZE_LONGVARCHAR Then
Data = Mid(str, CharsRead + 1, StrSize - CharsRead)
CharsRead = StrSize
Else
Data = Mid(str, CharsRead + 1, BLOCK_SIZE_LONGVARCHAR)
CharsRead = CharsRead + BLOCK_SIZE_LONGVARCHAR
End If
fld.AppendChunk Data
Loop
Else
' do something
End If
End Sub
Const BLOCK_SIZE_LONGVARCHAR = 4096
在我的报告或响应变量大于 32000 个字符之前,这可以正常工作。调用 rs.update 时我收到此错误消息:
“[Pervasive][ODBC 客户端接口] 字符串长度超过列长度参数 #15。数据被截断。”
谁能指出我正确的方向,或者让我知道我是否遗漏了什么。 Pervasive Longvarchar 最大大小应为 2GB。
谢谢, 格雷厄姆
【问题讨论】: