Page 1 of 1

Insert ,Modify or query on Mdb file

Posted: Tue Nov 08, 2005 12:11 pm
by Silvio
I make this test program :

Code: Select all

 function CategoM()
   local oDlg ,oWnd ,oLbx
   Local  oDbf
   local aData := {}
   Local nFor, oOdbc

   SET 3D LOOK ON

  * oOdbc := TOdbc():New("Database di Microsoft Access", "", "")
     oOdbc := TOdbc():New("Mwwind", "", "")
   If !oOdbc:lSuccess
      oOdbc:ShowErrorList("Sessione ODBC non inizializzata , Errore...")
      oOdbc:End()
      return nil
   Endif

   // Apro la tabella direttamente

   oDbf := TDbOdbcDirect():new( "SELECT * FROM SCategorie" , oOdbc)

  if oOdbc:IsError()
      oOdbc:ShowErrorList()
      oOdbc:aErrors := {}
      oDbf:End()
      return nil
   endif

   oDbf:Open()
   oDbf:Complete()

  // Creo il list box e i bottoni


        DEFINE DIALOG oDlg FROM 3, 3 TO 28, 79 TITLE "Gestione Categorie"
         @ 0,  1 SAY " &List"  OF oDlg
         @ 1, 1 LISTBOX oLbx FIELDS  str(oDbf:FieldGet(1)), oDbf:FieldGet(2)  ;
                             HEADER "Codice", "Categoria" ;
                             SIZE 284, 137 OF oDlg


   @ 9,  1 BUTTON "&Nuovo"    OF oDlg  SIZE 40, 12  action insercatm(oDbf)
   @ 9,  8 BUTTON "&Modifica" OF oDlg  SIZE 40, 12
   @ 9, 15 BUTTON "&Cancella" OF oDlg  SIZE 40, 12
   @ 9, 22 BUTTON "&Ricerca" OF oDlg  SIZE 40, 12
   @ 9, 29 BUTTON "&Stampa"  OF oDlg  SIZE 40, 12
   @ 9, 40 BUTTON "&Uscita"   OF oDlg ACTION oDlg:End()         SIZE 40, 12

   ACTIVATE DIALOG oDlg
      oDbf:End()
   oOdbc:End()

RETURN (NIL)



Now I must create the Insert Module ( I read FiveOdbc guide)

Code: Select all

   Function insercatm(oDbf)
oDbf:AddNew()
oDbf:Codice := 1

oDbf:Categoria := "Mysilvio"
oDbf:Update()


      return nil


it not run ..why ?