-3
我想將word文檔的所有圖像存儲在sql數據庫中。我發現了幾個關於如何通過InlineShapes
集合解析圖像的代碼示例,這些示例工作正常。但是,我現在錯過了如何將圖像存儲在sql服務器圖像列中的示例。在sql數據庫中存儲word文檔的圖像
任何人都可以發佈一個例子,其存儲在數據庫中的對象InlineShape
。請使用command
或recordset
對象?
更新:這裏是代碼
Sub SavePictures()
Dim SQL As String
Dim RS As ADODB.Recordset
Dim cnBon As ADODB.Connection
Dim intCount As Integer
Dim i As Integer
SQL = "Select [ID] ,[Datei] ,[Seite] ,[Bild] from Bilder Where 1=0"
strConn = "working Connection string"
Set cnBon = New ADODB.Connection
cnBon.Open strConn
Set RS = CreateObject("ADODB.Recordset")
RS.Open SQL, cnBon, adOpenKeyset, adLockOptimistic, adCmdText
For i = 1 To InlineShapes.Count
If InlineShapes.Item(i).Type = wdInlineShapePicture Then
RS.AddNew
RS("Datei") = ActiveDocument.Name
RS("Seite") = i
'This is where I'm stuck. How do I Access the Picture to save it in the Recordset?
RS("Bild") = InlineShapes.Item(i)
RS.Update
End If
Next i
RS.Close
cnBon.Close
Set RS = Nothing
Set cbbon = Nothing
End Sub