Autor Beitrag
Josef-B
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Mi 21.01.04 19:13 
Ich übernehme Daten per ACU-ODBC.

Wenn ich die Daten mit der Schnittstelle in MS-ACCESS übernehme, alles OK.

Bei der Übernahme per Delphi (BDE-TTABLE) werden in die Tabelle keine Kommas geschrieben (also z-B. 8,95 wird als 895 übernommen).
Es sind Felder mit Double Precision.

Weiß da jemand nen Tip?


Zuletzt bearbeitet von Josef-B am Mi 21.01.04 23:18, insgesamt 1-mal bearbeitet
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Mi 21.01.04 19:31 
Einen Tip habe ich nicht, aber ist denn die Zahl ohne Komma auch eine Zahl ?. Oder wird das zu Text konvertiert ?.

Falls gar nichts hilft, dann baue doch eine Division durch 100 ein. Ist zwar doof, aber löst das Problem.
KidPaddle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 351

WinXP,Linux
D7 Prof, XE7
BeitragVerfasst: Mi 21.01.04 20:13 
Ich vermute eher, das das Komma als Tausendertrennzeichen angesehen und daher ignoriert wird. Schau mal bitte nach, wie die Formatierungseinstellungen für Zahlen sind.

Gruß
KidPaddle
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Mi 21.01.04 20:34 
Ich bin da noch ziemlich neu,

was meinst Du genau, wo soll ich das nachsehen?
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Mi 21.01.04 23:08 
Also ich glaube das liegt tatsächlich gar nicht an dem ACU ODBC- das funktioniert. Wenn ich mir den Wert eines Feldes anzeigen lasse, dann wird als Preis1 z.B. 8,95 angezeigt. In folgendem Code habe ich sicherlich fälschlicherweise den Preis mit quotedstr. Als '8,95' übergeben, richtig ist aber doch 8.95 für Interbase/Firebird, oder? Wie wandele ich denn jetzt am besten die 8,95 in 8.95 um.

Wenn ich das Quotedstr weglasse kriege ich doch bestimmt Ärger mit dem Komma, weil der Rechner in der SQL-Anweisung 8,95 als Wert 8 und 95 ,für zwei Felder interpretiert?

(Das Feld Artikel_Nr ist hier tatsächlich vom Typ Char.)

ausblenden Delphi-Quelltext
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:
while not tablePREISE5.eof do begin {table eof}
    
    if tablePREISE5ARTIKEL_nr.value <> ''
    then begin 
          ibtransactionuni.active:= true;
          ibsqluni.SQL.Clear;
          sqlstring := 'INSERT INTO PREISE (' +

          'ARTIKEL_NR,' +
          'LAGER,' +
          'PREIS_1,' +
          'PREIS_2,' +
          'PREIS_3,' +
          'RUNDUNGSREIHE' +

          ') values (' +

           quotedstr(tablePREISE5ARTIKEL_NR.asstring) + ',' +
           quotedstr(tablePREISE5LAGER.asstring) + ',' +
           quotedstr(tablePREISE5PREIS_1.asstring) + ',' +
           quotedstr(tablePREISE5PREIS_2.asstring) + ',' +
           quotedstr(tablePREISE5PREIS_3.asstring) + ',' +
           quotedstr(tablePREISE5RUNDUNGSREIHE.asstring) + ')' ;
           ibsqlUNI.SQL.text := sqlstring;
           ibsqlUNI.ExecQuery;

...........
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Do 22.01.04 08:46 
Also dass "..asString" macht sicher keine Probleme, da in der Struktur der Datenbank ja der Feldtyp festliegt.


Das Tausendertrennzeichen kannst Du mal unter Systemsteuerung/ Ländereinstellungen überprüfen..

Ansonsten gäbe es u.a. in der JEDI-VCL (www.delphi-jedi.org) eine Funktion StrReplaceChar bei der Du einfach , durch . ersetzen könntest..
KidPaddle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 351

WinXP,Linux
D7 Prof, XE7
BeitragVerfasst: Do 22.01.04 09:23 
quotedstr() solltest Du nur bei Textfeldern verwenden. Wenn Du mit SQL die Daten einfügst, dann must Du 8,95 als 8.95 speichern, da hier die Landeseinstellungen ignoriert werden.

Das geht mit dem Befehl FloatToStr(Wert, formatSettings).

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
// manuelles setzen der benoetigten Felder
formatSettings.ThousandSeparator := ',';
formatSettings.DecimalSeparator := '.';

oder
// Lese English US aus
GetLocaleFormatSettings($0409, formatSettings);

...
  FloatToStr(tablePREISE5PREIS_1.asFloat, formatSettings);
  FloatToStr(tablePREISE5PREIS_2.asFloat, formatSettings);
  FloatToStr(tablePREISE5PREIS_3.asFloat, formatSettings);
...


Gruß
KidPaddle
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Do 22.01.04 09:35 
KidPaddle hat recht sorry. Ich habe das mit .asString verwechselt. Quotedstr funktioniert natürlich nur mit Text.

FloatToStr ist aber nicht unproblematisch, weil es nicht immer "kaufmännisch" rundet. Hatte selbst mal Probleme bei einem Projekt, deshalb würde ich es nicht mehr verwenden..
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Do 22.01.04 10:38 
Hi Kidpaddle,

wie muß ich den den Ausdruck formatsettings deklarieren,
'ThousandSeparator ist ein char oder?


ausblenden Quelltext
1:
formatSettings.DcimalSeparator := '.';					


Meine Zahlen werden ohne Tausender-Trennzeichen übermittelt.
Dann brauche ich doch nur das formatsettings für das Decimal-Zeichen oder?
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Do 22.01.04 13:29 
Das ist in SysUtils deklariert. Hier ein Auszug

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
var DecimalSeparator: Char;
var CurrencyDecimals: Byte;
var DateSeparator: Char;
var ShortDateFormat: string;
var LongDateFormat: string;
var TimeSeparator: Char;
var TimeAMString: string;
var TimePMString: string;
var ShortTimeFormat: string;

var LongTimeFormat: string;
var ShortMonthNames: array[1..12of string;
var LongMonthNames: array[1..12of string;
var ShortDayNames: array[1..7of string;
var LongDayNames: array[1..7of string;

var SysLocale: TSysLocale;
var EraNames: array[1..7of string;
var EraYearOffsets: array[1..7of Integer;
var TwoDigitYearCenturyWindow: Word = 50;

var TListSeparator: Char;


Du kannst das direkt im Programm setzen z.B.

ausblenden Delphi-Quelltext
1:
DecimalSeparator:='.';					
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Do 22.01.04 14:46 
sorry, kannst Du mir mal den kompletten Code posten?

Ich versteh das leider nicht.

Was ist denn Sysutil?

Dieses 'formatsettings' brauch ich dann gar nicht mehr?
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Do 22.01.04 15:40 
Die Unit, in der diese Variablen deklariert sind heisst SYSUTILS. Die muss in Deiner Uses Liste dazu, wenn sie nicht schon drin ist..

Nein, Du kannst das dann wie in meinen letzten Beispiel direkt im Programm setzen.

ausblenden Delphi-Quelltext
1:
DecimalSeparator:='.';					
KidPaddle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 351

WinXP,Linux
D7 Prof, XE7
BeitragVerfasst: Do 22.01.04 15:46 
Wenn er es global setzt, dann sind alle Konvertierungen davon betroffen, inbesondere dann, wenn er die Werte aus einer Datei ausliest. Auch die Anzeige der Daten erfolgt dann mit '.' und nicht mehr mit ',' als Dezimaltrennzeichen.

@Josef-B
Das Tausendertrennzeichen wird in den meisten Fällen ignoriert und kann ruhig gesetzt werden.
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Do 22.01.04 15:58 
Ich denke ,wenn er es vor der Datenübernahme setzt und sich das vorher gesetzte Zeichen merkt, dann ist das sicher o.k. :wink:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
alteszeichen:= DecimalSeparator;
Decimalseparator:='.':


...Import der Daten...

DecimalSeparator:=alteszeichen;
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Do 22.01.04 18:08 
tomtom,

habe es genauso gemacht.

Danke, klappt super und die Werte stehen jetzt auch richtig drin.

Josef