I want use a file MDB on Xharbour( &fw) with ado or another class
I want open a table and make insert,mod,search and print
there is some example to make it ?
Regards
Silvio
function Prodotti()
local oBCli , oWChld ,oDlg ,oWnd ,oLbx
Local oDbf
local aData := {}
Local nFor, oOdbc
SET 3D LOOK ON
oOdbc := TOdbc():New("Database di Microsoft Access", "", "")
If !oOdbc:lSuccess
oOdbc:ShowErrorList("Sessione ODBC non inizializzata , Errore...")
oOdbc:End()
return nil
Endif
// Apro la tabella direttamente
oDbf := TDbOdbcDirect():new( "SELECT * FROM prodotti" , 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 Prodotti"
@ 0, 1 SAY " &Demo" OF oDlg
@ 1, 1 LISTBOX oLbx FIELDS str(oDbf:FieldGet(1)), oDbf:FieldGet(2),oDbf:FieldGet(5) ;
HEADER "ID", "Codice", "Prodotto" ;
SIZE 284, 137 OF oDlg
@ 9, 1 BUTTON "&Nuovo" OF oDlg SIZE 40, 12 action EditClient( oLbx, .t. )
@ 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)
static function EditClient( oLbx, lAppend )
local cName
local cAddress
local cPhone
local nOldRec := RecNo()
DEFAULT lAppend := .f.
if lAppend
GOTO BOTTOM
SKIP
endif
cName = Clientes->Nombre && field0001
cAddress = Clientes->Direccion && field0002
cPhone = Clientes->Telefono && field0003
DEFINE DIALOG oDlg FROM 8, 2 TO 25, 65 ;
TITLE If( lAppend, "New Customer", "Customer Update" )
@ 1, 1 SAY "&Name:" OF oDlg
@ 1, 6 GET cName OF oDlg
@ 2, 1 SAY "&Address:" OF oDlg
@ 2, 6 GET cAddress OF oDlg
@ 3.5, 23 SAY "&Phone:" OF oDlg
@ 4, 21 GET cPhone OF oDlg SIZE 60, 11 PICTURE "@R 99-999-9999999"
@ 6, 9 BUTTON "&Acept" OF oDlg SIZE 50, 12 ACTION ( lSave := .t. , oDlg:End() )
@ 6, 19 BUTTON "&Cancel" OF oDlg SIZE 50, 12 ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
if lSave .and. !empty( cName )
if lAppend
APPEND BLANK
endif
Clientes->Nombre := cName
Clientes->Direccion := cAddress
Clientes->Telefono := cPhone
oLbx:Refresh() // We want the ListBox to be repainted
else
if Empty( cName ) .and. lSave
MsgAlert( "Please write a name" )
endif
GOTO nOldRec
endif
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 45 guests