Setting the value of an Informix v7.3 BLOB field using ADO, VFP and OLEDB
Posted in 2003
Hi everyone, I'm trying to replace an Informix v7.3 BLOB field in an existing record with a .PDF file and it's giving me fits! I've adapted the KB article Q258038 (http://support.microsoft.com/default.aspx?scid=kb;EN-US;258038) to work in VFP, but I"m getting the error: "OLE exception error: Exception code c0000005. OLE object may be corrupt" When I execute the loRecordSet.UpdateBatch command. I do know that the document on disk is OK, I can open it in Acrobat and it looks fine. I've also tried using other .PDF's with the same results. I've also tried the ADLOCKOPTIMISTIC/Update combo with the same results. I'm not very well versed in ADO so I find myself googling all day hunting for leads. Any expert knowledge would be appreciated. FYI - I've tried other cursor types, but the others error out saying "Scroll cursor can't select blob columns". See below for my code. ====================================== #include "I:\\COMMON\\adovfp.h" LOCAL lcConnStr, lcSQL, loConnection, lcImageName, ; loRecordSet, loADOStream lcConnStr = 'Provider=Ifxoledbc.2;' +; 'Password=Password;' + ; 'Persist Security Info=True;' +; 'User ID=UserID;' +; 'Data Source=MyDatabase@MyServer' lcSQL = "SELECT dm_id, dm_seq, dm_doc FROM informix.document WHERE dm_id = 22280 AND dm_seq = 0" *!* Creates the objects. loConnection = CREATEOBJECT("ADODB.Connection") loRecordSet = CREATEOBJECT("ADODB.Recordset") loADOStream = CREATEOBJECT("ADODB.Stream") *!* Open the connections. loConnection.OPEN(lcConnStr) loRecordSet.CursorLocation = adUseClient loRecordSet.OPEN(lcSQL,loConnection,ADOPENFORWARDONLY,ADLOCKBATCHOPTIMISTIC, 1) *!* Set Stream Object properties. loADOStream.TYPE = 1 && 1=Binary Data, 2=Text Data. loADOStream.OPEN loADOStream.LoadFromFile("I:\\INFORMIX\\inDocument.pdf") && Pass data to the stream object. loRecordSet.Fields("dm_doc").Value = loADOStream.Read loRecordSet.UpdateBatch *!* Close connections. loRecordSet.CLOSE loConnection.CLOSE loADOStream.CLOSE ====================================== Thanks. -- William Fields MCSD - Microsoft Visual FoxPro MCP - Win2k Pro US Bankruptcy Court Phoenix, AZ "While the complexity of this project is several orders of magnitude less than modeling heat flux in a fossil-fuel fired electric utility plant using the Hottel Zone technique, the context of each project evolves in a remarkably similar fashion." - Author Unknown