The sort order at the beginning is correct, but after you press refresh button the sequence changes.
I am using the buildh.bat file in samples folder to compile and link.
Code: Select all
#include "fivewin.ch"
REQUEST HB_CODEPAGE_TRWIN
static oCn
function Main()
local oRs, oDlg, oBrw, oFont
HB_SetCodePage("TRWIN")
FWCONNECT oCn HOST "localhost" USER "root" PASSWORD "mypassw" DATABASE "test" PORT 3306 CHARSET "latin5"
oCn:lShowErrors := .T.
CreateTables()
oRs := oCn:RowSet( "SELECT CUSTID,FIRST FROM test_trk ORDER BY FIRST" )
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12
DEFINE DIALOG oDlg SIZE 500,600 FONT oFont PIXEL TRUEPIXEL TITLE "EditBaseRecord()"
@ 70,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs AUTOCOLS AUTOSORT ;
COLSIZES -10, -30 ;
CELL LINES NOBORDER
oBrw:CreateFromCode()
@ 20, 20 BTNBMP PROMPT "ADD" SIZE 100,30 PIXEL FLAT OF oDlg ;
ACTION oRs:EditBaseRecord( nil, .t., { |oRec| MyEditDlg( oRec ) }, oBrw )
@ 20,130 BTNBMP PROMPT "EDIT" SIZE 100,30 PIXEL FLAT OF oDlg ;
ACTION oRs:EditBaseRecord( nil, .f., { |oRec| MyEditDlg( oRec ) }, oBrw )
@ 20,240 BTNBMP PROMPT "REFRESH" SIZE 100,30 PIXEL FLAT OF oDlg ;
ACTION ( oRs:Requery(), oBrw:Refresh(), oBrw:SetFocus() )
ACTIVATE DIALOG oDlg CENTERED
oFont:End()
return nil
function CreateTables()
oCn:DropTable( "test_trk" )
if !oCn:TableExists( "test_trk" )
oCn:CreateTable( "test_trk", { ;
{ "CUSTID", 'N', 3, 0, "PRI" }, ;
{ "FIRST", 'C', 20, 0 }, ;
{ "SECOND", 'C', 20, 0 } } )
oCn:Insert( "test_trk", "CUSTID, FIRST, SECOND", ;
{ {1, 'A', 'B'}, {2, 'Ş', 'B'}, {3, 'Z', 'B'}, {4, 'W', 'B'}, {5, 'B', 'B'}, ;
{6, 'Q', 'B'}, {7, 'N', 'B'}, {8, 'İ', 'B'}, {9, 'Ü', 'B'} } )
endif
return nil
static function MyEditDlg( oRec )
local lNew := ( oRec:RecNo == 0 )
local oDlg, oFont
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12
DEFINE DIALOG oDlg SIZE 400,300 PIXEL TRUEPIXEL FONT oFont
@ 030,020 SAY "ID:" SIZE 80,20 PIXEL OF oDlg RIGHT
@ 060,020 SAY "First" SIZE 80,20 PIXEL OF oDlg RIGHT
@ 090,020 SAY "Second" SIZE 80,20 PIXEL OF oDlg RIGHT
@ 030,120 GET oRec:CUSTID SIZE 100,22 PIXEL OF oDlg
@ 060,120 GET oRec:FIRST SIZE 240,22 PIXEL OF oDlg
@ 090,120 GET oRec:SECOND SIZE 240,22 PIXEL OF oDlg
@ 140,020 BTNBMP PROMPT "Save" SIZE 150,30 PIXEL FLAT OF oDlg ;
ACTION ( If( oRec:Modified(), oRec:Save(), nil ), oDlg:End() )
@ 140,240 BTNBMP PROMPT "Cancel" SIZE 150,30 PIXEL FLAT OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED ON PAINT oDlg:Box( 15, 10, 125, 390 )
return nil