Autor Beitrag
rob87
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Fr 07.09.07 13:06 
Hallo,

ich möchte eine Spalte einer Tabelle mit der Variablen Programm.Name vergleichen.
Der Datentyp der Spalte in der Tabelle ist Char(20). Nun sagt mir mein Debugger: Inkompatible Datentypen.


Ich dacht, dass Char und String in etwa dasselbe sind?? Dafür gibts ja keinen TypeCast oder?
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: Sa 08.09.07 01:57 
user profile iconrob87 hat folgendes geschrieben:
Hallo,

ich möchte eine Spalte einer Tabelle mit der Variablen Programm.Name vergleichen.
Der Datentyp der Spalte in der Tabelle ist Char(20). Nun sagt mir mein Debugger: Inkompatible Datentypen.


Ich dacht, dass Char und String in etwa dasselbe sind?? Dafür gibts ja keinen TypeCast oder?


Hallo,

Char(20) ist der ASCII-Buchstabe DC4, gibt aber keinen Sinn, was du wahrscheinlich meinst: char[20], aber das ist C, nicht Pascal. Der entsprechende Pascal-Typ ist array [0..19] of char.

Sortier erst mal deine Sprachen und die Schreibweisen.

Gruss Reinhard
rob87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mo 10.09.07 06:50 
Ich möchte einfach folgendes vergleichen:

if Tabelle1['Spalte1'] = Programm.Name
then ...

( und der Datentyp der Spalte ist Char(20) )

Ich darf aber den Datentyp der Spalte ned verändern.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 10.09.07 06:54 
Was für einen Typ hat Programm.Name ?

_________________
Markus Kinzler.
rob87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mo 10.09.07 07:06 
String[20] Das "normale" Programm.Name von Delphi halt
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 10.09.07 07:32 
user profile iconrob87 hat folgendes geschrieben:
if Tabelle1['Spalte1'] = Programm.Name
then ...
Ich vermute, dass Tabelle1 vom Typ TTable ist.
Versuche mal:
ausblenden Delphi-Quelltext
1:
2:
if Tabelle1.FieldByName('Spalte1').AsString = Programm.Name    
  then ...
rob87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mo 10.09.07 07:38 
Sorry, Die Tabelle ist vom Typ TADOTable
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 10.09.07 07:39 
Da müsste es aber genauso gehen.

_________________
Markus Kinzler.
rob87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mo 17.09.07 08:57 
Hmmm... Bei mir gehts ned.

Wie gesagt. Des is ein Char[20] und des andere ein String [20]
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 17.09.07 09:00 
Aber ein Feld in der Datenbank vom Typ Char müsste automatisch auf den Delphi-Typ String gemappt werden.

_________________
Markus Kinzler.
rob87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mo 17.09.07 09:04 
user profile iconrob87 hat folgendes geschrieben:
Hmmm... Bei mir gehts ned.

Wie gesagt. Des is ein Char[20] und des andere ein String [20]


Nochmal der Quellcode:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
  if Tabelle1['Spalte1'] = Wert1 and Tabelle2['Spalte2'] = Programm.NAME then
    begin                                                            //  Char[20]   =?   String[20]
      if Tabelle1['ZUGRIFF'] = 'j' then

        begin

          //Akt. Menüpunkt (aus Spalte Menue_Name) Enabled := true;
        end
        else begin
          //Akt. Menüpunkt (aus Spalte Menue_Name) Enabled := false;
        end;
    end
  else begin
    //leer
  end;
Pille
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 105

Windows 7
DelphiXE Prof.
BeitragVerfasst: Mo 17.09.07 11:22 
user profile iconrob87 hat folgendes geschrieben:


Nochmal der Quellcode:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
  if Tabelle1['Spalte1'] = Wert1 and Tabelle2['Spalte2'] = Programm.NAME then
    begin                                                            //  Char[20]   =?   String[20]
      if Tabelle1['ZUGRIFF'] = 'j' then

        begin

          //Akt. Menüpunkt (aus Spalte Menue_Name) Enabled := true;
        end
        else begin
          //Akt. Menüpunkt (aus Spalte Menue_Name) Enabled := false;
        end;
    end
  else begin
    //leer
  end;


Versuchs mal so:
ausblenden Delphi-Quelltext
1:
if (Tabelle1['Spalte1'] = Wert1) and (Tabelle2['Spalte2'] = Programm.NAME) then					


Mit freundlichen Grüßen
Pille
rob87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mo 17.09.07 12:29 
Vielen Dank.

Wenn sich doch bloß alle Probleme so leicht beheben lassen würden. ;-)