28,391
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Const strPath="c:\test.jpg"
Dim objXml,objAds,objCon,objRst
On Error Resume Next
Set objCon=CreateObject("adox.catalog").create("Provider=microsoft.jet.oledb.4.0; data source=test.mdb")
If err Then
Set objCon=CreateObject("adodb.connection")
objCon.open "Provider=microsoft.jet.oledb.4.0; data source=test.mdb"
End If
objCon.execute "CREATE TABLE tblBinTest(bin IMAGE)"
On Error goto 0
Set objRst=CreateObject("adodb.recordset")
objRst.open "tblBinTest",objCon,0,3,2
If objRst.eof Or objRst.bof Then
Set objAds=CreateObject("adodb.stream")
objAds.Type=1
objAds.Mode=3
objAds.open
objAds.loadFromFile strPath
objRst.addNew
objRst("bin").appendChunk objAds.read
objRst.update
objAds.close
Set objAds=Nothing
End If
Set objXml=CreateObject("msxml.domdocument")
Set objXml.documentElement=objXml.createElement("Root")
objXml.documentElement.DataType="bin.hex"
objXml.DocumentElement.NodeTypedValue=objRst("bin").getChunk(objRst("bin").actualSize)
MsgBox "0x" & Left(objXml.documentElement.Text,255)