PowerBuilder9.0 DataWindow's Update (my PB learning for the second day)

xiaoxiao2021-03-06  17

HEHE

In the past two or three days, it is a bitter update database of DataWindow. Help several people. Everyone gives only some of the possible TIPs. The most is modified UPDATE properties, even tried, Describe (ColumnName.Update) Is waiting yes, or it is said that there is no Update Ability. There is a prompt to Key. If you want Yes, you will go to modify (key = yes) results still. Close up to give up. Think about it, or look at the results Set the primary key, and the results have not found that the table structure is changed, and it is finally possible.

Sometimes it is really a low-level mistake ~

Let's talk about it, let's talk about Update.

Background introduction: DW_SRC is the source data window, DW_TARGET dynamically binds the data object A, and the operation is made to copy DW_SRC to dw_target, then update DW_TARGET. It should be noted that the structure of A is consistent with DW_SRC data object structure. And A There must be Primary Key

Source code:

Long ll_col_count, ll_istring ls_column [], ls_column_type [], sql

LL_COL_COUNT = long (dw_test.describe ("datawindow.column.count")))

// Take the column name of the source data window, and type for ll_i = 1 to ll_col_count if dw_src.describe ("#" string (ll_i) ". Visible") = '1' TEN // Column name LS_COLUMN [LL_i] = dw_src.describe ("#" string (ll_i) ". Name") // Column type ls_column_type [ll_i] = dw_src.describe (ls_column [ll_i] ". ColType") end ifnext

// Dynamic Binding table Astring Errorssql = "Select * from a" dw_target.create (Sqlca.SyntaxFromsql (SQL, "Style (Type = Grid)", Errors)

If LEN (ERRORS)> 0 THEN MessageBox ("Note", "Errors:" Errors) End IF DW_TARGET.SETTRANSOBJECT (SQLCA) DW_TARGET.RETRIEVE ()

/ / Modify Update Properties = YES for LL_i = 1 To LL_COL_COUNT DW_TARGET.MODIFY (LS_COLUMN [LL_I] ". Update = 'yes'" ls_column [ll_i] ". UpdatewhereClause = 'yes'") Next

IF dw_target.accepttext () = -1 Then Return End IF

// Row copy if dw_src.rowscopy (1, dw_src.rowcount (), primary!, Dw_target, 1, primary!) = 1 Then MessageBox ("Tips", "Copy Success") Else MessageBox ("Tips", "Copy Failure ") End IF

IF dw_target.Update () = 1 THEN MessageBox ("Tips", "Save Success") Else MessageBox ("Tips", "Save Fail") End IF

转载请注明原文地址:https://www.9cbs.com/read-41946.html

New Post(0)