I use the demo GdPicture [Pro] ActiveX. I try to convert other database table with data , but error is the same. what is the problem?
Code VBScript:
- Code: Select all
Set objConn = CreateObject("ADODB.Connection")
ConnectString = "ConnectString"
objConn.ConnectionString = ConnectString
objConn.Open
TEXT = "SELECT GRA_ID,GRD_GRAPHIC,DOC_EXTENSION FROM GRAPHICS"
Set objRecordset = objConn.Execute(TEXT)
While Not objRecordset.EOF
GRA_ID = CStr(objRecordset.Fields(0).Value)
GRD_GRAPHIC = objRecordset.Fields(1).Value
EXTENSION = CStr(objRecordset.Fields(2).Value)
Set filesys = CreateObject("Scripting.FileSystemObject")
Set oGdPicture = CreateObject("gdpicturepro5.imaging")
oGdPicture.SetLicenseNumber("XXXX")
' Write file
Set filetxt = filesys.CreateTextFile("C:\1\"+GRA_ID+"."+EXTENSION, True)
filetxt.WriteLine( BinaryToString(GRD_GRAPHIC))
filetxt.Close
HND = oGdPicture.CreateImageFromFile("C:\1\"+GRA_ID+"."+EXTENSION)
oGdPicture.SaveAsPNG ("C:\1\"+GRA_ID+".PNG")
oGdPicture.CloseImage(HND)
'Delete file
Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.DeleteFile("C:\1\"+GRA_ID+"."+EXTENSION)
objRecordset.MoveNext
Wend
'=======================================================
objConn.Close
Function BinaryToString(Binary)
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(Binary)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
BinaryToString = pl1 & pl2 & pl3
End Function
