Advanced PowerBuilder

HomePrevious Lesson: Getting Image From the Database to OLE Control
Next Lesson: Copying the OLE Control

Updating the Database BLOB Column from OLE Control

Similar to populating the object in the OLE Control, we can also update the database column once user updates the object in the OLE control. The following code updates "screen" column in the "examples_previews" table in the database.

Blob lBlob
Integer lResult

lBlob = ole_1.ObjectData

SqlCa.AutoCommit = True

UPDATEBLOB "examples_previews"
set "examples_previews"."screen" = :lBlob
where "examples_previews"."window" = 'w_dialer';

If SqlCa.SqlCode <> 0 or SQLCA.SQLNRows = 0 Then
Rollback using Sqlca ;
MessageBox( "Error", Sqlca.uf_GetError())
Return -1
Else
Commit using Sqlca ;
End If

Similar to the SELECTBLOB, we are calling UPDATEBLOB, not a regular UPDATE database statement.

To see it in the action, run the application. Select "Module/OLE 2.0 Control Examples" option from the menu. Click on the "Save to Database Using BLOB" CommandButton.
HomePrevious Lesson: Getting Image From the Database to OLE Control
Next Lesson: Copying the OLE Control