Not finding an example in the tech database so here is some code I chopped out of a program.
Jim
SQLText = "select copy_order, copy_requestor, copy_requestor_id, copy_budget, copy_location from copy_cat where copy_profile = '%copy_profile%' order by copy_order"
myREC.Open (SQLText, myConn, adoConst.adOpenStatic, adoConst.adLockReadOnly, adoConst.adCmdText)
If myREC.EOF == @FALSE Then
copy_cat_arr = myREC.GetRows()
DialogControlSet(COP_Handle,"rv_COP_copy_cat",@dcContents, copy_cat_arr)
Else
copy_cat_arr = ArrDimension(1,11)
ArrInitialize(copy_cat_arr, " ")
DialogControlSet(COP_Handle,"rv_COP_copy_cat",@dcContents,copy_cat_arr)
EndIf
myREC.Close
For what it is worth...The sorting isn't perfect as you have to click twice sometimes but not sure it can be made better than this due to the way sorting is implemented. I am going to post a question under dialogs about the sorting. You may want different style attributes.
This does use the native dialog constants. Hopefully that won't be a problem.
Jim
Home_Path = DirScript()
DirChange(Home_Path)
GoSub Load_Routines
IntControl(49,3,0,0,0)
My_Connection()
STANFormat=`WWWDLGED,6.2`
STANCaption=`Stan Grid`
STANX=-01
STANY=-01
STANWidth=554
STANHeight=301
STANMinWidth=298
STANMinHeight=301
STANNumControls=003
STANProcedure=`DEFAULT`
STANProcedure=`Stan_Sub`
STANTextColor=`DEFAULT`
STANBackground=`DEFAULT,6|28|85`
STANConfig=4513740
STAN001=`525,003,022,012,PUSHBUTTON,"pb_STA_Exit",DEFAULT,"E&xit",1,3,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
STAN002=`005,003,022,012,PUSHBUTTON,"pb_STA_Load",DEFAULT,"Load",6,27,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
STAN003=`005,017,542,278,REPORTVIEW,"rv_STA_copy_cat",copy_cat_arr,DEFAULT,DEFAULT,39,@csAsort|@csFirstHeader|@csFullSel|@csGrid|@csNoAdjust|@csSingleSel,"Courier New|6144|40|49","0|0|0",DEFAULT`
ButtonPushed=Dialog("STAN")
My_Connection_Close()
Exit
:Load_Routines
#DefineSubRoutine Stan_Sub(STA_Handle,DMsg,DCID,DEInfo,ChangeInfo)
Switch (DMsg)
Case @deInit
DialogProcOptions(STA_Handle, @deClose,1) ; Close selected (IntControl(49....) (1-On, 0-Off).
DialogProcOptions(STA_Handle, @deTimer,0) ; TimerEvent (0- Off).
DialogProcOptions(STA_Handle, @dePbPush,1) ; Pushbutton/PictureButton.
DialogProcOptions(STA_Handle, @deRvrSelect,1) ; RV Item Select Row.
DialogProcOptions(STA_Handle, @deRvhClick,1) ; RV Edit Item Text.
copy_cat_sort_col = 1
Get_CopyCat_List()
Break
Case @deTimer
x = copy_cat_sort_col_new
If copy_cat_sort_col_new == copy_cat_sort_col Then
If copy_cat_sort_ord_%x% == @ASCENDING Then
copy_cat_sort_ord_%x% = @DESCENDING
DialogControlState(STA_Handle,"rv_STA_copy_cat",@dcsRemStyle,@csAsort)
DialogControlState(STA_Handle,"rv_STA_copy_cat",@dcsAddStyle,@csDsort)
Else
copy_cat_sort_ord_%x% = @ASCENDING
DialogControlState(STA_Handle,"rv_STA_copy_cat",@dcsRemStyle,@csDsort)
DialogControlState(STA_Handle,"rv_STA_copy_cat",@dcsAddStyle,@csAsort)
EndIf
Else
copy_cat_sort_ord_%x% = @ASCENDING
DialogControlState(STA_Handle,"rv_STA_copy_cat",@dcsRemStyle,@csDsort)
DialogControlState(STA_Handle,"rv_STA_copy_cat",@dcsAddStyle,@csAsort)
EndIf
copy_cat_sort_col = copy_cat_sort_col_new
DialogProcOptions(STA_Handle, @deTimer,0)
Break
Case @deClose
Return 9
Break
Case @deRvhClick
Switch(DialogProcOptions(STA_Handle,@dpoCtlNumber,DCID))
Case DialogProcOptions(STA_Handle,@dpoCtlNumber,"rv_STA_copy_cat")
copy_cat_sort_col_new = ChangeInfo
DialogProcOptions(STA_Handle, @deTimer, 1)
Break
EndSwitch
Break
Case @deRvrSelect
Switch(DialogProcOptions(STA_Handle,@dpoCtlNumber,DCID))
Case DialogProcOptions(STA_Handle,@dpoCtlNumber,"rv_STA_copy_cat")
copy_cat_idx = ChangeInfo
copy_cat_arr = DialogControlGet(STA_Handle,"rv_STA_copy_cat",@dcSelect)
grid_idx_old = ""
Break
EndSwitch
Break
Case @dePbPush
Switch(DialogProcOptions(STA_Handle,@dpoCtlNumber,DCID))
Case DialogProcOptions(STA_Handle,@dpoCtlNumber,"pb_STA_Exit")
Return -1
Break
Case DialogProcOptions(STA_Handle,@dpoCtlNumber,"pb_STA_Load")
Get_CopyCat_List()
Break
EndSwitch
Break
EndSwitch
Return -2
#EndSubRoutine
#DefineSubRoutine Get_CopyCat_List()
If !IsDefined(copy_cat) Then copy_cat = ""
copy_profile = "Jim"
SQLText = "select copy_order, copy_requestor, copy_requestor_id, copy_budget, copy_area, copy_location, copy_collection, copy_itype, copy_extra1, copy_extra2, copy_extra3, copy_extra4, copy_note, copy_copies, copy_num from copy_cat where copy_profile = '%copy_profile%' order by copy_order"
myREC.Open (SQLText, myConn, adoConst.adOpenStatic, adoConst.adLockReadOnly, adoConst.adCmdText)
If myREC.EOF == @FALSE Then
copy_cat_arr = myREC.GetRows()
DialogControlSet(Sta_Handle,"rv_Sta_copy_cat",@dcContents,copy_cat_arr)
copy_cat = copy_cat_arr[0,0]
col_cnt = myREC.Fields.Count
header_text = ""
col_width = ""
col_form = ""
For x = 0 to col_cnt-1
header_text = header_text:myREC.Fields(x).Name:@TAB
col_width = col_width:"-2 "
col_form = col_width:"0 "
y = x+1
copy_cat_sort_ord_%y% = @ASCENDING
Next
header_text = ItemRemove(1,header_text,@TAB)
col_form = ItemReplace("2",1,col_form," ") ;RIGHT JUSTIFY
col_form = ItemReplace("1",2,col_form," ") ;CENTER
col_form = ItemReplace("2",3,col_form," ") ;RIGHT JUSTIFY
col_form = ItemReplace("2",12,col_form," ") ;RIGHT JUSTIFY
col_form = ItemReplace("2",14,col_form," ") ;RIGHT JUSTIFY
Else
header_text = "No Rows"
col_width = "-2"
col_form = ""
copy_cat = ""
copy_cat_arr = ArrDimension(1,11)
ArrInitialize(copy_cat_arr, " ")
EndIf
myREC.Close
DialogControlSet(Sta_Handle,"rv_Sta_copy_cat", @dcContents, copy_cat_arr)
DialogControlSet(Sta_Handle,"rv_Sta_copy_cat",@dcHeaderText,header_text)
DialogControlSet(Sta_Handle,"rv_Sta_copy_cat",@dcColWidth,col_width)
DialogControlSet(Sta_Handle,"rv_Sta_copy_cat",@dcColFormat,col_form)
DialogControlSet(Sta_Handle,"rv_Sta_copy_cat",@dcSelect,copy_cat)
#EndSubRoutine
#DefineSubRoutine My_Connection()
jserver = ""
jport = ""
juid = ""
jpwd = ""
jdb = ""
;############################
; Establish the connection
;############################
myConn = ObjectOpen('ADODB.Connection')
myREC = ObjectOpen('ADODB.Recordset')
myREC.CursorLocation = 3
myConn.ConnectionString = "Driver={MySQL ODBC 5.1 Driver}; Server=%jserver%; UID=%juid%; PWD=%jpwd%; Option=71303168; Database=%jdb%"
myConn.CommandTimeout = 360
adoConst = ObjectConstantsGet(myConn)
myConn.Open
#EndSubRoutine
#DefineSubRoutine My_Connection_Close()
myConn.Close
ObjectClose(myREC)
ObjectClose(myConn)
#EndSubRoutine
Return