Autor Beitrag
bockwurst
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 191

win98 /XP
D1 D5 Prof DE2005PE
BeitragVerfasst: Do 03.02.05 09:23 
Hallo zusammen,
habe ein Problem, will mit localSQL (ParadoxTabellen) Felder hinzufügen.

Dies mache ich in etwa so

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
 with KonvertQuery do
 begin
   Close;
   KonvertQuery.DatabaseName := DBName;
   Sql.Clear; 
   SQL.ADD('ALTER TABLE TabelName '+
           'ADD NeuerFeldName CHAR(15)');
   try
     EXECSQL;
   except
     on E: Exception do
       FehlerListe.Add(E.Message);  // eine Stringliste
   end;
 end;  //  with KonvertQuery do


Bei einer exception will ich nun NICHT in Fehlerliste schreiben, wenn das Feld schon existiert. D.h. wenn E.Message so etwa lautet: "Tabellen Name nicht eindeutig" (dann kommen noch andere Zeilen).

Liefert die Exception einen Fehlercode, oder wie kann ich es machen. Ich will/kann vorher nicht mit einer Table und Findfield prüfen. Das würde alles zu langsam gehen.

danke

Andreas
atarigold
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 84

WIN XP, Linux 2.4
D7, Delphi 2006 Prof
BeitragVerfasst: Fr 04.02.05 19:27 
Hallo,

eine Liste von BDE-Fehhlercodes gibts unter

www.swissdelphicente...y/showcode.php?id=37

Ohne deinen Anwendungsfall zu kennen:
-aber eigentlich sollte, wenn das DB-Design stimmt, überhaupt nicht notwendig sein zur Laufzeit Attribute zu ergänzen.
MarkusB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Fr 04.02.05 22:08 
Moin bockwurst!

Versuch so etwas:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
  try
    …
    deine DataBase-Operation
    …
  except
    on e: EDBEngineError do
    begin
      for i:=0 to e.ErrorCount - 1 do
      begin
        error_no := e.Errors[0].ErrorCode;
        MessageDlg(e.Message + #13 + 'Error no: ' + IntToStr(error_no), mtError, [mbOK], 0);
      end;
    end;
  end;


Noch eine Bemerkung zu deinem code:

ausblenden Delphi-Quelltext
1:
2:
3:
...
KonvertQuery.DatabaseName := DBName;
...

sieht IMHO sehr verdächtig aus.

Viele Grüße
Markus
:gruebel:
bockwurst Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 191

win98 /XP
D1 D5 Prof DE2005PE
BeitragVerfasst: Mo 14.02.05 10:18 
Titel: Vielen Dank
Vielen Dank an atarigold + MarkusB den BDE-Göttern,
habe mein Problem lösen können.

Andreas