Application written in VB6. DB is Pervasive v9.5.
Currently works:
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
This works fine until my report or response variable is larger than 32000 characters. I receive this error message when rs.update is called:
“[Pervasive][ODBC Client Interface] String length exceeds column length Parameter #15. Data truncated.”
Can anyone point me in the right direction or let me know if I am missing something. Pervasive Longvarchar max size should be 2GB.
Thanks,
Graham
This code works form me using PSQL v11 (I don’t have v9.5).
Basically, you would use parameterized queries rather than the .AddNew method.