Home » Open Source » Programming Interfaces » VBScript(ASP): Update from Image File data to Blob Value into Oracle DB table
VBScript(ASP): Update from Image File data to Blob Value into Oracle DB table [message #681095] Mon, 15 June 2020 20:55 Go to next message
AlbertHung021
Messages: 1
Registered: June 2020
Junior Member
Dim adTypeBinary
adTypeBinary = 1
Dim Stream
Dim ReadBinaryData
Set Stream = CreateObject("ADODB.Stream")
Stream.Type = adTypeBinary
Stream.Open
Stream.LoadFroomFile "D:\Temp\Image.jpg"
ReadBinaryData = Stream.Read

Dim conn, rs, sqlString
' [the datatype of ImageContent field is 'Blob' Type from the ImageTable Table]
sqlString = "Update ImageTable set ImageContent = to_blob('" & readBinaryValue & "') where image_id = 999"
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=OraOLEDB.Oracle.1;... "
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlString, conn, adOpenStatic
Finally, the record cannot be updated and get error. So I have tried to Response.Write sqlString, but it only displays "Update ImageTable set ImageContent = to_blob('???
I hope you can help me. Thanks.
Re: VBScript(ASP): Update from Image File data to Blob Value into Oracle DB table [message #681096 is a reply to message #681095] Tue, 16 June 2020 01:06 Go to previous message
Michel Cadot
Messages: 67570
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Welcome to the forum.
Please read the OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Indent the code, make sure that lines of code do not exceed 100 characters.

Also always post your Oracle version, with 4 decimals (query v$version), as often solution depends on it.

Quote:
to_blob('" & readBinaryValue & "')

This part is not correct, you must use a bind variable.
Or something like (in VB, fix the differences in syntax for VBScript):

Dim OraRecSet As ADODB.Recordset
sqlString = "Select ImageContent from ImageTable where image_id = 999"
Set OraRecSet = New ADODB.Recordset
OraRecSet.Open sqlString, conn, adOpenDynamic, adLockOptimistic
Set Stream = CreateObject("ADODB.Stream")
Stream.Type = adTypeBinary
Stream.Open
Stream.LoadFromFile "D:\Temp\Image.jpg"
OraRecSet.Fields("IMAGECONTENT").Value = Stream.Read
OraRecSet.Update
...
Previous Topic: Using oracle to generate e-commerce website
Goto Forum:
  


Current Time: Fri Dec 04 06:02:14 CST 2020