Escolar Documentos
Profissional Documentos
Cultura Documentos
Lazarus e Firebird Embarcado
Lazarus e Firebird Embarcado
Para criao de um aplicativo em Lazarus com banco de dados Firebird Embarcado, iremos usar um passo a passo para criao de uma agenda para gerenciamento de numero de telefone.
Materiais
Lazarus Compilador Pascal, gratuito.
Clique na Imagem para baixar e ter mais informaes sobre o projeto Lazarus.
Servidor Firebird Embedded Verso do banco de dados que pode ser distribudo junto ao aplicativo.
Clique na Imagem para baixar e ter mais informaes sobre o projeto Servidor Firebird Embedded.
Clique na Imagem para baixar e ter mais informaes sobre o projeto Flamerobin.
Montagem
1) Cria base de dados com o Flamerobin
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
SET NAMES WIN1252; CREATE DATABASE 'AGENDA2.FDB' USER 'SYSDBA' PASSWORD 'masterkey' PAGE_SIZE 16384 DEFAULT CHARACTER SET WIN1252; CREATE GENERATOR GERADOR_CHAVE; SET GENERATOR GERADOR_CHAVE TO 0; CREATE TABLE AGENDA ( IAGENDA INTEGER NOT NULL, NOME VARCHAR(30), SOBRENOME VARCHAR(30), NUMERO VARCHAR(20) ); CREATE TRIGGER AGENDA_BI FOR AGENDA ACTIVE BEFORE INSERT POSITION 0 as begin if ((new.iagenda is null) or (new.iagenda = 0)) then new.iagenda = gen_id(gerador_chave,1); end;
1 2 3 4
Configurao do TIBConnection.
3) Insero ou atualizao dos registros feito pela sequencia de cdigos abaixo:
1 2 3 4 5 6 7 8 1 2 3 4 5
update or insert into agenda (iagenda, nome, sobrenome, numero) values (:iagenda, :nome, :sobrenome, :numero) matching(iagenda);
6 7 8 9
1 delete from agenda ag where ag.iagenda = :iagenda; 2 1 2 3 4 5 if MessageDlg('Apagar','Deseja apagar'+#32+ edit1.Text+#32+ 6 edit2.Text+'?',mtInformation,[mbOk, 7 mbCancel],0)=mrOk 8 then 9 begin 1 //----------------------------with self.SQLQuery3 do begin 0 close; 1 ParamByName('iagenda').AsInteger:=strtoint(edit4.Text); ExecSQL; 1 SQLTransaction3.Commit; 1 end; 2 self.atualizarGrid; 1 //----------------------------3 end; 1 4 1 5
5) Atualizar registos apos a insero de dados segue a sequncia abaixo:
1 2 3
Anexos
Baixar: Agenda Programa Baixar: Projeto Agenda