I am trying to become familiar with the operation of ADO in various settings.
I downloaded the working function I call below ADO_DBF() from a thread on this forum.
When I compile ADO_DBF() by itself, all menus, etc. work fine.
But when I bring ADO_DBF() in as a short version of a menuing c:\fwh\samples\Fwbrow.prg,
if I try any operation it crashes.
If oRs:close(), oCN:close() are commented out, the ADO_DBF() function works fine again.
What am I doing wrong ??
Any help
Thanks,
Bruce S.
//------------------------
#include 'adodef.ch'
#include "FiveWin.ch"
#include "hbcompat.ch"
#include 'xbrowse.ch'
static oWnd
//----------------------------------------------------------------------------//
function Main()
local oBrush, oBar, oBmp
SET _3DLOOK ON // Microsoft 3D Look
SkinButtons()
DEFINE BRUSH oBrush STYLE TILED // FiveWin new predefined Brushes
DEFINE WINDOW oWnd FROM 4, 4 TO 25, 75 ;
TITLE FWVERSION + " - Browsing power" ;
MENU BuildMenu() ;
BRUSH oBrush
DEFINE BUTTONBAR oBar OF oWnd
DEFINE BUTTON FILENAME "..\bitmaps\Exit.bmp" OF oBar ;
ACTION If( MsgYesNo( "Do you want to End ?", "Please, Select" ), oWnd:End(), ) ;
MESSAGE "End this session"
DEFINE BUTTON FILENAME "..\bitmaps\Ques2.bmp" OF oBar ;
MESSAGE "FiveWin info" ACTION MsgAbout()
SET MESSAGE OF oWnd TO FWVERSION + FWCOPYRIGHT CLOCK DATE
ACTIVATE WINDOW oWnd //;
//ON RESIZE oBmp:Center()
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "&Information"
MENU
MENUITEM "&About..." + Chr( 9 ) + "Alt+A" ;
ACTION MsgAbout( FWCOPYRIGHT, FWVERSION ) ;
MESSAGE "Some information about this demo" ;
ACCELERATOR ACC_ALT, Asc( "A" ) ;
FILENAME "..\bitmaps\16x16\info.bmp"
SEPARATOR
MENUITEM "&Exit demo..." ACTION ;
If( MsgYesNo( "Do you want to end ?", "Please, Select" ), oWnd:End,) ;
MESSAGE "End the execution of this demo"
ENDMENU
MENUITEM "&Options"
MENU
MENUITEM "&ADO dbf" ACTION ADO_Dbf();
MESSAGE "ADO DBF"
MENUITEM "&Calculator..." ACTION WinExec( "Calc" ) ;
MESSAGE "Calling Windows Calculator"
ENDMENU
ENDMENU
return oMenu
//-------------------------------------------
func ado_dbf() // Date : 10/02/14
// Update : 10/02/14
// Use : ADO browse
// Taken from : AS IS sample of Dbf thru ADO - nages 07/23/14 FW_www
local oCn, oRs
local oWndB, oFont, oBrw, oMiSort
SET DATE AMERICAN //ITALIAN
SET CENTURY ON
oCn := FW_OpenAdoConnection( "c:\hev\" )
oRs := FW_OpenRecordSet( oCn, "SALES" )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE WINDOW oWndB TITLE "Nages ADO browser"
oWndB:SetFont( oFont )
DEFINE BUTTONBAR oWndB:oBar SIZE 100,32 2010
DEFINE BUTTON OF oWndB:oBar PROMPT "Add" ACTION oBrw:Edit( .t. )
DEFINE BUTTON OF oWndB:oBar PROMPT "Edit" ACTION oBrw:Edit()
DEFINE BUTTON OF oWndB:oBar PROMPT "Delete" ACTION oBrw:Delete()
DEFINE BUTTON OF oWndB:oBar PROMPT "Report" ACTION oBrw:Report()
DEFINE BUTTON OF oWndB:oBar PROMPT "Close" ACTION oWndB:End()
SET MESSAGE OF oWndB TO "" 2010
DEFINE MSGITEM oMiSort PROMPT If( Empty( oRs:Sort ), "NATURAL", oRs:Sort ) ;
SIZE 200
oMiSort:bMsg := { || If( Empty( oRs:Sort ), "NATURAL", oRs:Sort ) }
@ 0,0 XBROWSE oBrw OF oWndB DATASOURCE oRs ;
AUTOCOLS AUTOSORT CELL LINES NOBORDER FOOTERS
//AEval( oBrw:aCols, { |o| If( o:cDataType == 'N', o:nFooterType := AGGR_SUM, nil ) } )
WITH OBJECT oBrw
:nEditTypes := EDIT_GET
:bLClickHeaders := { || oMiSort:Refresh() }
:MakeTotals()
//
:CreateFromCode()
END
oWndB:oClient := oBrw
ACTIVATE WINDOW oWndB
RELEASE FONT oFont
// If I comment out these 2 lines , the function works OK
oRs:Close()
oCn:Close()
return nil
//--------------------- END -----------------//
FWH 14.08
Harbour 3.2.0dev
BCC582
I have tried this .prg on 2 machines
XP2002 SP3
&
W7 Home premium
Xbrowse ADO
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Xbrowse ADO
A window does not wait for execution, it is not a dialog, thats why you have to keep the recordset and the connection active and open.
Re: Xbrowse ADO
If I keep oRs & oCn open any operation on the Xbrowse crashes it.
What is the proper way to implement ADO_DBF() inside this menu setup ?
I have tried replacing oWnd with oDlg , don't know if that's compatible, unless I made a typo, it didn't work.
Or, should I get it all inside a define dialog.
Beginner stuff, but that's where I'm at.., stuck.
Bruce S
What is the proper way to implement ADO_DBF() inside this menu setup ?
I have tried replacing oWnd with oDlg , don't know if that's compatible, unless I made a typo, it didn't work.
Or, should I get it all inside a define dialog.
Beginner stuff, but that's where I'm at.., stuck.
Bruce S
Re: Xbrowse ADO
Try the following change on the ACTIVATE WINDOW statement inside func ado_dbf()
Code: Select all
ACTIVATE WINDOW oWndB ;
VALID ( oRs:Close(), oCn:Close(), .T. )
Re: Xbrowse ADO
Mr anserkk,
Thank you for your reply.
That has solved my problem.
------
Similar to an electrical circuit with no grounding, now I make the connection.
Thanks to all,
Bruce S.
Thank you for your reply.
That has solved my problem.
------
Similar to an electrical circuit with no grounding, now I make the connection.
Thanks to all,
Bruce S.