Salut les gens
n'étant pas très expérimenté en delphi (j'utilise toujours les meme choses), je cherche un moyen simple d'utiliser une base de donnée pour stocker des noms, adresse, références etc, tout restera en local
apparemment dbase et tdbf correspondent bien à ce que je cherche mais on ne trouve pas beaucoup d'infos
à terme ça sera sous lazarus mais en bricolant j'ai réussi à faire ça qui marche et me permet d'ouvrir le fichier dbf sous open office calc:
bon après y aura des boucles et tout mais c'est propre de faire ça? je n'oublie rien ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 procedure TForm1.btnGoClick(Sender: TObject); begin try Dbf1.FilePathFull := ExtractFilePath(Application.ExeName)+'bdd\'; Dbf1.TableLevel := 4; //DBase IV //Dbf1.Exclusive := True; Dbf1.TableName := 'customers.dbf'; With Dbf1.FieldDefs do begin Add('CUST_NO', ftInteger); Add('FIRST_NAME', ftString, 15); Add('LAST_NAME', ftString, 20); End; Dbf1.CreateTable; Dbf1.Open; Dbf1.Append; dbf1.FieldByName('CUST_NO').AsInteger := 1; dbf1.FieldByName('FIRST_NAME').AsString := 'Serge'; dbf1.FieldByName('LAST_NAME').AsString := 'Herisson'; Dbf1.Post; Dbf1.Append; dbf1.FieldByName('CUST_NO').AsInteger := 5; dbf1.FieldByName('FIRST_NAME').AsString := 'Luc'; dbf1.FieldByName('LAST_NAME').AsString := 'Durand'; Dbf1.Post; Dbf1.Close; finally Dbf1.Free; end; ShowMessage('Fini'); end; procedure TForm1.btnAddClick(Sender: TObject); begin try Dbf1.FilePathFull := ExtractFilePath(Application.ExeName)+'bdd\'; Dbf1.TableLevel := 4; //DBase IV Dbf1.TableName := 'customers.dbf'; Dbf1.Open; Dbf1.Append; dbf1.FieldByName('CUST_NO').AsInteger := 427; dbf1.FieldByName('FIRST_NAME').AsString := 'Raymond'; dbf1.FieldByName('LAST_NAME').AsString := 'Palvico'; Dbf1.Post; Dbf1.Append; dbf1.FieldByName('CUST_NO').AsInteger := 221; dbf1.FieldByName('FIRST_NAME').AsString := 'André'; dbf1.FieldByName('LAST_NAME').AsString := 'Gerflor'; Dbf1.Post; Dbf1.Close; finally Dbf1.Free; end; ShowMessage('Fini'); end;
merci d'avance
Partager