FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBROWSER ODBC / ADO -> read only ?
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
XBROWSER ODBC / ADO -> read only ?
Posted: Mon Jul 17, 2023 11:54 AM
hi,

i try c:\fwh\samples\testodbc.prg and c:\fwh\samples\access.prg (BUG ISKINDOF)
i can open "Edit" but all are "read only" :shock:

what do i miss :?:
greeting,

Jimmy
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: XBROWSER ODBC / ADO -> read only ?
Posted: Mon Jul 17, 2023 03:50 PM
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBROWSER ODBC / ADO -> read only ?
Posted: Tue Jul 18, 2023 05:38 AM
Using fwh\samples\access.prg, the msaccess database of Read/Write.
We revised access.prg and here it is:
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

static oCn

//----------------------------------------------------------------------------//

function Main()

   local aTables
   local cDataBase   := "xbrtest.mdb"

   FW_SetUnicode( .t. )
   SetGetColorFocus()
   SET DATE GERMAN
   SET CENTURY ON
   FWNumFormat( "E", .t. )

   if !( Right( cFilePath( ExeName() ), 9 ) .XEQ. "\samples\" )
      ? "Build this program in fwh\samples\ folder"
      QUIT
   endif

   cDataBase   := cFileSetExt( cDataBase, "mdb" )
   if !File( cDataBase)
      FW_CreateMDB( cDataBase )
   endif
   oCn   := FW_OpenAdoConnection( cDataBase, .t. )
   if oCn == nil
      ? "Connection fail"
      QUIT
   endif
   ? "connected"

   ImportDBF()

   ListTables()

   oCn:Close()

return nil

//----------------------------------------------------------------------------//

static function ImportDBF()

   local aTables  := { "states", "customer", "wwonders" }
   local cTable, cDbf

   for each cTable in aTables
      cDBF     := cTable + ".dbf"
      if !FW_AdoTableExists( cTable, oCn ) .or. ;
         MsgNoYes( "Re-Create table " + cTable + " ?"  )
         TRY
            oCn:Execute( "DROP TABLE " + cTable )
         CATCH
         END
         FW_AdoImportFromDBF( oCn, cDBF )
      endif
   next

return nil

//----------------------------------------------------------------------------//

static function ListTables()

   local aTables, oRs
   local oDlg, oBar, oBrw, oFont

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 400,400 PIXEL TRUEPIXEL ;
      FONT oFont RESIZABLE TITLE "Tables"
   DEFINE BUTTONBAR oBar OF oDlg SIZE 100,32 2010
   @ 42,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE FW_AdoTables( oCn ) COLUMNS 1 ;
      HEADERS "Table" CELL LINES NOBORDER FOOTERS

   WITH OBJECT oBrw
      :nStretchCol   := 1
      :lHScroll      := .f.
      :RecSelShowKeyNo()
      :CreateFromCode()
   END

   DEFINE BUTTON OF oBar PROMPT "Browse" CENTER ACTION ;
      BrowseTable( oBrw:aCols[ 1 ]:Value )
   DEFINE BUTTON OF oBar PROMPT "Edit" CENTER ACTION ;
      ( oRs := FW_OpenRecordSet( oCn, oBrw:aCols[ 1 ]:Value ), ;
        XEdit( oRs ), oRs:Close() )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//

static function BrowseTable( cTable )

   local oDlg, oBar, oFont, oBrw, oRs

   oRs   := FW_OpenRecordSet( oCn, cTable )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL ;
      FONT oFont RESIZABLE TITLE cTable
   DEFINE BUTTONBAR oBar OF oDlg SIZE 100,32 2010

   @ 42,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS ;
      FASTEDIT FOOTERS CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :SetChecks()
      :AutoFit()
      :RecSelShowKeyNo()
      :CreateFromCode()
   END

   DEFINE BUTTON OF oBar PROMPT "Add"    CENTER ACTION oBrw:EditSource( .t. )
   DEFINE BUTTON OF oBar PROMPT "Edit"   CENTER ACTION oBrw:EditSource()
   DEFINE BUTTON OF oBar PROMPT "Delete" CENTER ACTION oBrw:Delete( .t. )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oRs:Close()

return nil
Please copy this program to 32-bit fwh\samples folder overwriting the existing access.prg and build with
Code (fw): Select all Collapse
buildh access
You can write modifications in xbrowse and also xedit()
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: XBROWSER ODBC / ADO -> read only ?
Posted: Tue Jul 18, 2023 08:26 PM
hi,
nageswaragunupudi wrote:Using fwh\samples\access.prg, the msaccess database of Read/Write.
We revised access.prg and here it is:

Please copy this program to 32-bit fwh\samples folder overwriting the existing access.prg and build with
Great, thx
greeting,

Jimmy

Continue the discussion