Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to Insert ActiveDocument.Content into a SQL BLOB

Status
Not open for further replies.

nemosys

Programmer
Oct 10, 2001
5
US
I have Word Script that is trying to insert the contents of a document into a SQL/2000 database field. It keeps failing with an error code of "Multiple-step operation generated errors. Check each status value." Here is a piece of the code:

Set cn = CreateObject("ADODB.Connection")
cn.ConnectionString = "Provider=sqloledb;Data Source="
cn.ConnectionString = cn.ConnectionString & "PHILL\SQL2000" & ";Initial Catalog=" & "umantest" & ";User id=sa;password=;"
cn.CursorLocation = adUseClient
cn.Open
Set Cmd = CreateObject("ADODB.Command")
Set Cmd.ActiveConnection = cn
rs.Open "select * from policy where PKPOL1 = " &
policy, cn, adOpenKeyset, adLockOptimistic
Set rngMainText = ActiveDocument.Content
rs!DOM = rngMainText.Text
* This is where the error occurs !!!!!!!

How can I convert the document content to a BLOB field ?
Is there a way to do a cast to a BlOB?

Thanks.
 
Public Sub SelectionAndRangeExample()
' This procedure shows various ways to work with Selection
' and Range objects within a document.
Dim rngSelection As Word.Range
Dim rngRange As Word.Range

Selection.Collapse

Set rngRange = ActiveDocument.Sentences(1)
rngRange.Select
MsgBox "You have created a Range object representing the first " _
& "sentence in this document." & vbCrLf & "When the Range " _
& "object was selected, both the Range object and the " _
& "Selection object referred to the same portion of the " _
& "document."

Set rngSelection = ActiveDocument.Content
rngSelection.Select

MsgBox "The Selection object now represents the entire document " _
& "whereas the Range object still contains only this text: '" _
& rngRange.Text & "'"

Set rngRange = ActiveDocument.Paragraphs(2).Range
Set rngSelection = rngRange
With rngRange
.Select
MsgBox "The Selection object and the Range object once again refer " _
& "to the same text: " & vbCrLf & vbCrLf & "Selection = " _
& Selection.Range.Text & vbCrLf & "Range = " _
& .Text
End With
End Sub

'Hope it helps Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top