Previous Topic

Next Topic

Inhoudsopgave

Book Index

TIsahCDSSQLUpdateObject Component

TxUpdateSQLTIsahCDSSQLUpdateObject

Description

TIsahCDSSQLUpdateObject provides functionality used to update datasets represented by a TIsahCDSQuery component using SQL statements.

Details

In practical application, a TIsahCDSSQLUpdateObject object is linked to a TIsahCDSQuery component through that component's UpdateObject property. The objects are used in combination with data-aware visual components.

The update object actually encapsulates three TIsahQuery components. Each of these query components perform a single update task. One query component provides an SQL UPDATE statement for modifying existing records; a second query component provides an INSERT statement to add new records to a table; and a third component provides a DELETE statement to remove records from a table.

At runtime, when the update component is used to apply updates, it:

TxUpdateSQLTIsahCDSSQLUpdateObject Properties

Property Property ModifySQL:TStringList object (R/W)

Specifies the UPDATE statement.

Property Property InsertSQL:TStringList object (R/W)

Specifies the INSERT statement.

Property Property DeleteSQL:TStringList object (R/W)

Specifies the DELETE statement.

Property Property Timestampfield:String (R/W)

Specifies the timestampfield of the table to be mutated.

Code Snippet

Update without data-aware controls

Set quUpdate = IsahObjects.Get("TIsahQuery")

With quUpdate

.Name = "quUpdate"

.DatabaseName = "dbIsahAdmin"

.UpdateObject = "usqlUpdate"

.SQL.Add "exec SIP_sel_ScriptExampleRS"

End With

Set usqlUpdate = IsahObjects.Get("IsahCDSSQLUpdateObject")

With usqlUpdate

.Name = "usqlUpdate"

End With

xusqlUpdate.ModifySQL.Add "exec SIP_upd_ScriptExample "

xusqlUpdate.ModifySQL.Add "@old_CountryCode = :CountryCode"

xusqlUpdate.ModifySQL.Add ", @old_LastUpdatedOn = :LastUpdatedOn"

xusqlUpdate.ModifySQL.Add ", @Description = 'last description'"

xusqlUpdate.ModifySQL.Add ", @IsahUserCode = '" & Application("IsahUserCode") &"'"

xquUpdate.Open

xquUpdate.First

xquUpdate.Edit

xquUpdate.Post

xquUpdate.Refresh

xquUpdate.Close

Code Snippet

Update with data-aware controls

Set quScriptExample = IsahObjects.Get("TIsahCDSQuery")

With quScriptExample

.Name = "quScriptExample"

.DatabaseName = "dbIsahAdmin"

.UpdateObject = "usqlScriptExample"

.SQL.Add "exec SIP_sel_ScriptExampleRS"

.Left = 272

.Top = 8

End With

Set xusqlScriptExample = IsahObjects.Get("TIsahCDSSQLUpdateObject")

With usqlScriptExample

.Name = "usqlScriptExample"

.Left = 304

.Top = 8

End With

Set dsScriptExample = IsahObjects.Get("TDataSource")

With dsScriptExample

.Name = "dsScriptExample"

.DataSet = "quScriptExample"

.AutoEdit = True

.Left = 336

.Top = 8

End With

Set dbedtDescription = IsahObjects.Get("TDBEdit")

With dbedtDescription

.Parent = grpbxCountry

.Name = "dbedtDescription"

.Left = 76

.Top = 36

.Width = 216

.Height = 21

.DataField = "Description"

.DataSource = "dsScriptExample"

.TabOrder = 1

End With

usqlScriptExample.ModifySQL.Add "EXEC SIP_upd_ScriptExample "

usqlScriptExample.ModifySQL.Add "@old_CountryCode = :CountryCode"

usqlScriptExample.ModifySQL.Add ", @old_LastUpdatedOn = :LastUpdatedOn"

usqlScriptExample.ModifySQL.Add ", @Description = :Description"

usqlScriptExample.ModifySQL.Add ", @IsahUserCode = 'ISAH'"

quScriptExample.Open