1. How to get the count of the Group?
A. cumulativeSum (if (group column name [-1] = group column name [0], 0, 1) for all)
B. GetRow ()-First (GetRow () for Group 1) + 1
C. count (grouping field for all distinct)
2. How to get the row number of the Group?
CumulativeSum (1 for group 1)
3. How to pass parameters to a subdata window?
Datawindowchild ldwc_name
Ldwc_name = dw_name.getchild ('column ', ldwc_name)
// If you do not know what the search parameters of dddw are, you can fool dddw and let him think that the data already exists:
Ldwc_name.insertrow (0)
Dw_name.retrieve ()
// If you know the search parameters:
Ldwc_name.settransobject (sqlca)
Ldwc_name.retrieve (arguments)
Dw_name.settransobject (sqlca)
Dw_name.retrieve ()
4. How to compare the days of data difference between two time (date) types?
Date ld_date1, ld_date2
Long ll_diff
Ll_diff = daysafter (ld_date1, ld_date2)
5. In DW, each row of data is displayed in different colors.
Background. color express:
If (mod (getrow (), 2) = 0, rgb (0,255, 0), rgb (255,255,255 ))
6. Operation of the visible attribute in the window
Way1: select option from the design menu of the window canvas, and click the show invisible check box.
Way2: select control list from the edit menu, select the button you want to find, and click the visible check box in the property.
7. How to calculate columns in dw
Put the computing domain in the summary band, such as sum (column for all)
8. How do I get the server time and change the local time?
FUNCTION ulong SetLocalTime (any lpSystemTime) LIBRARY \ "kernel32.dll \"
Str_policime (unsignedinteger: year, month, day, hour, minute, second)
Datetime dt_server
Str_policime lstr_tmp
Select getdate () into: dt_server from sysfiles;
Lstr_tmp.year = year (date (dt_server ))
Lstr_tmp.month = month (date (dt_server ))
Lstr_tmp.week = daynumber (date (dt_server)-1
Lstr_tmp.day = day (date (dt_server ))
Lstr_tmp.hour = hour (time (dt_server ))
Lstr_tmp.minute = minute (time (dt_server ))
Lstr_tmp.second = second (time (dt_server ))
SetLocalTime (lstr_tmp)
9. How can I block the press enter in datewindow?
Pbm_dwnprocessenter: return 1
10. incremental query of dddw?
Datawindowchild ldwc_name
Dw_name.getchild ("column", ldwc_name)
// Dw_name: editchanged
Ldwc_name.setfilter ("column Like '%" + upper (daTa) + "% '")
Ldwc_name.filter ()
11. How can I dynamically change dw SQL statements?
String ls_ SQL, ls_new_ SQL
Ls_ SQL = dw_name.getsqlselect ()
Ls_new_ SQL = ls_ SQL + 'Statement'
Dw_name.setsqlselect (ls_new_ SQL)
Dw_name.settransobject (sqlca)
Dw_name.retrieve ()
12. How do I know which rows have been modified in the data window?
Long I
Dwitemstatus lds_status
For I = 1 to dw_name.rowcount ()
Lds_status = dw_name.getitemstatus (I, 0, primary! )
If lds_status <> notmodified! Then
// This row has been modified
End if
Next
13. How to dynamically modify the style of data window columns?
Dw_name.object.columnname.edit.style = 'dddw '// or other style
Dw_name.object.columnname.edit.case = 'any' // change back to edit
#2
1. Is the data Window Automatically Folded?
Detail autosize height
Column remove auto horz scroll select auto vert scroll
2. How to dynamically set the fields in a data window to read-only
Dw_name.object.column.protect = 1
Dw_name.object.column.edit.displayonly = 'yes'
Dw_name.object.column.teasequence = 0
3. How to implement distributed queries or updates across databases?
// Establish a connection with the other party
String ls_link, ls_login
Ls_link = "sp_addmediaserver ~ 'Srv _ lnk ~ ',~ '~ ',~ 'Sqloledb ~ ',~ 'Sws ~ '"
Ls_login = "sp_add1_srvlogin ~ 'Srv _ lnk ~ ',~ 'False ~ ', Null ,~ 'Sa ~ ',~ 'Newworld ~ '"
Sqlca. autocommit = true
Execute immediate: ls_link;
Execute immediate: ls_login;
// Modify ansi_nulls and ansi_warnings. Because you should set all distributed queries to on. The ansi_nulls and ansi_warnings options in enterprise management are incorrect, but there is no way to change them. You can set ansi_nulls and ansi_warnings options in the query analyzer, and the default value is correct. Therefore, create a stored procedure,
Create proc name as set ansi_null_dflt_on -- pay attention to set ansi_warnings on
Declare procedure up_set for your_proc... // Delete the stored procedure created in Pb.
// Perform data operations
Insert into tableofanotherdb values ('19', 'uuu ', 'dd ');
// Close the connection
String ls_drop
Ls_drop = "sp_dropserver ~ 'Srv _ lnk ~ ',~ 'Droplogins ~ '"
Execute immediate: ls_drop;
Sqlca. autocommit = false
4. how to read and write images with pb?
// Image field
String docname, named
Integer value, li_f, I
Integer li_fileptr, li_loops
Long ll_filelen, ll_bytes_read
Blob lbb_Read, lbb_Total
Value = GetFileOpenName ("select image file", + docname, named, "BMP", + "Bmp Files (*. BMP ),*. BMP, "+" Jpeg Files (*. JPG ),*. JPG ")
IF value = 1 THEN
// Open the image file
Ll_filelen = FileLength (docname) // get the file length, which must be before opening
Li_fileptr = FileOpen (docname, STREAMMODE !, READ !, LOCKREAD !)
If li_fileptr =-1 Then
Beep (2)
MessageBox ("error", "Image File opening error! ")
Return
End If
If ll_filelen> 32765 Then // only 32 KB can be read at a time
If Mod (FIG, 32765) = 0 Then
Li_loops = ll_filelen/32765
Else
Li_loops = (ll_filelen/32765) + 1
End If
Else
Li_loops = 1
End If
// Read image files cyclically
For I = 1 to li_loops
Ll_bytes_read = FileRead (li_fileptr, lbb_Read)
Lbb_Total = lbb_Total + lbb_Read
Next
FileClose (li_fileptr)
SetPicture (p_1, lbb_Total)
UPDATEBLOB table set column =: lbb_total where clause;
End if
// Display the image
Blob lbb_blob
Selectblob column into: lbb_blob from table wher clause;
Setpicture (p_1, blob)
5. Is there a function like winamp that allows users to select a directory?
Getfileopenname ()
Getfilesavename ()
Dirlist ()
#3
When designing a data window report, because the width of a field is fixed, some data cannot be completely displayed, so we want to implement automatic line feed, at the same time, in order to save the paper space, the height of this field is also required to be automatic. I wonder if you have any tips? (Please note that there seems to be some difference between Chinese and English. Now both of them are required)
---------------------------------------------------------------
Deselect auto horz scroll of the corresponding column in the data window and select autosize height.
Select the autosize height of detail. Call the following function after retrieve in the data window.
Uf_set_text (datawindow adw_content, string
As_columns, boolean, AB _ignoreblank)
/*************************************** **********************
Describe: In the data window adw_content, insert spaces in the columns included in as_columns
Args:
As_columns multiple columns to be operated, separated by commas
**************************************** *********************/
If (not isvalid (adw_content) or isnull (as_columns) or len (as_columns) <1 or isnull (AB _ignoreblank) then return-1
N_cst_string lnv_string
String ls_column [], ls_width, as_source, as_replaced, ls_temp
Int li_upperbound, li_width, li_column, li_fontWidth, li_counter
Long ll_rowcount, ll_row, ll_totalstep
Int li_yield
Lnv_string.of_parsetoarray (as_columns, ',', ls_column)
Li_upperbound = upperbound (ls_column)
Ll_rowcount = adw_content.rowcount ()
If li_upperbound <1 or ll_rowcount <1 then return-1
Openwithparm (w_waiting, this)
Ib_cancel = false
Iw_frame.enabled = false
Ll_totalstep = ll_rowcount * li_upperbound
W_waiting.uf_register (ll_totalstep)
For li_column = 1 to li_upperbound
Ls_width = adw_content.describe (ls_column [li_column] + ". width ")
Li_width = INTEGER (ls_width)
If ls_width = '! 'Or ls_width = '? 'Or li_width = 0 then
Continue
End if
// Ls_temp = adw_content.describe (ls_column [li_column] + ". Font. Property {= 'width '}")
// MessageBox (ls_column [li_column] + ". Font. Property {= 'width'}", ls_temp)
// Return 1
Li_fontwidth = 27
Li_counter = li_width/li_fontwidth
For ll_row = 1 to ll_rowcount
If ib_cancel then
Iw_frame.enabled = true
Return 0 // pressed cancel button
End if
As_source = adw_content.getitemstring (ll_row, ls_column [li_column])
As_replaced = uf_insertstring (as_source, li_counter, '', false)
If as_replaced <> as_source then
Adw_content.setitem (ll_row, ls_column [li_column], as_replaced)
End if
W_waiting.uf_stepit ()
Next
Next
Close (w_waiting)
Iw_frame.enabled = true
Return 1
#4
In the data window, how does one change the color of the cell where the cursor is located?
I want to determine the column number where the current cursor is located, so that the background color of the cell where the cursor is located changes.
(Note: You can use
Dw_1.modify (dwo. Background. Color = \ "color value \") change. But it changes
The color of the entire column. Now I want to change the color of the cell where the cursor is located .)
What I want is:
1. The cursor is a color in the cell of a column in a row. The cursor leaves the cell. For example, when the cursor moves to the left or right column, the original cell color is restored, the color of the cell column to be moved changes (Note: The cursor is in the same row)
2. When the cursor moves to the next row, the color of the cell in which the light table is located can only change between the same column, and the other upper and lower cells remain unchanged.
---------------------------------------------------------------
In the dw itemfocuschanged event, note the ITEMFOCUSCHANGED event:
// Declare the variables used here;
Long ll_col, ll_pos, ll_cols
String modstring, ls_colnam, ls_color_1, ls_color_2
// Assign values to the two color variables;
Ls_color_1 = String (RGB (0,255, 0 ))
Ls_color_2 = String (RGB (255, 0, 0 ))
// Obtain the current column number and total number of columns;
Ll_col = dw_1.GetColumn ()
Ll_cols = long (dw_1.object.data?#column.count)
// Set the mode attribute of the background of all columns to opacity. (Note: The following two statements can be executed in the form open event or dw constructor to improve efficiency ;)
For ll_pos = 1 to ll_cols
Ls_colnam = dw_1.describe ("#" + String (ll_pos) + ". Name ")
Dw_1.modify (ls_colnam + ". Background. mode = '0 '")
Next
// Set the background. Color Attribute of the operated column to an expression with the if judgment, and the background expressions of other columns to constant values;
For ll_pos = 1 to ll_cols
Ls_colnam = dw_1.describe ("#" + String (ll_pos) + ". Name ")
If ll_pos <> ll_col then
Modstring = ls_colnam + ". Background. Color = '" + ls_color_1 + "'"
Else
Modstring = ls_colnam + ". Background. Color = '" + ls_color_1 + "~ T if (getrow () = currentrow (), "+ ls_color_2 +", "+ ls_color_1 + ")'"
End if
// Modify the background color;
Dw_1.modify (modstring)
// Refresh and display the new background color;
Dw_1.setredraw (true)
Next
The final running effect is that the current item is red, and the others are green.