Thanks for the replies.
Mark, I would like the sample if it is not too late. Thanks.
> That will work until myTextField (actually, until the sum size of all fields
> returned) contains more than 8060 bytes. Beyond that you'll need to use
[quoted text clipped - 15 lines]
> >> with out the store procedure if so please tell me where I can go to learn
> >> how to do it. Thanks
Mark J. McGinty - 29 Sep 2004 15:35 GMT
> Thanks for the replies.
>
> Mark, I would like the sample if it is not too late. Thanks.
Not too late at all. Below are two functions, the first will write the
contents of StringBuffer to the field specified in FieldName. The recordset
rs is assumed to be open and the contents of FieldName must match a field
text in it (of course.)
The second function is much the same, except that it accepts the FQ name of
a file, and writes the contents of that file to a column of type image.
Hope this helps,
Mark
Sub StuffText(StringBuffer As String, _
FieldName As String, _
rs As ADODB.Recordset _
)
Dim s As ADODB.Stream
Set s = New ADODB.Stream
s.Mode = adModeReadWrite
s.Type = adTypeText
' By default a text stream will have a unicode char set
' which must be changed if you're going to use ANSI data
'
' Since you're writing a field of type text the default char set
' won't work. If you're writing ntext, leave it as default
'
s.Charset = "Windows-1252" ' setting may depend on locale/collation
s.Open
s.WriteText StringBuffer
s.Position = 0
rs.Fields(FieldName).Value = s.ReadText()
rs.Update
s.Close
Set s = Nothing
End Sub
Sub StuffBlob(FileName As String, _
FieldName As String, _
rs As ADODB.Recordset _
)
Dim s As ADODB.Stream
Set s = New ADODB.Stream
s.Mode = adModeReadWrite
s.Type = adTypeBinary
s.Open
' load binary contents of into stream
'
s.LoadFromFile FileName
s.Position = 0
rs.Fields(FieldName).Value = s.Read()
rs.Update
s.Close
Set s = Nothing
End Sub