Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 23.03.13 08:10 
Hi, Delpher,

(wie) kann ich zur Laufzeit die Connection, z.B. von AdoConnection1 zu AdoConnection2 ändern?

Detlef

_________________
ut vires desint, tamen est laudanda voluntas
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Sa 23.03.13 08:45 
Den Datasets die andere Connection zuweisen und öffnen ... oder meinst Du etwas anderes?

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 23.03.13 08:46 
Hi, Bummi,

ja, genau so meine ich es.

Detlef

_________________
ut vires desint, tamen est laudanda voluntas
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Sa 23.03.13 09:18 
Dann kannst Du ja aus folgendem, das basteln was für Dich am besten passt ...(lässt sich je nach Intention massiv kürzen)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm3.Button1Click(Sender: TObject);
var
 l:TList;
 i:Integer;
begin
   l:=TList.Create;
   try
    for i := 0 to AdoConnection1.DataSetCount -1 do
      if AdoConnection1.DataSets[i].Active then
        l.Add(AdoConnection1.DataSets[i]);
    for I := 0 to l.Count - 1 do
      TAdoDataset(l[i]).Connection := nil;
    for I := 0 to l.Count - 1 do TAdoDataset(l[i]).Close;
    for I := 0 to l.Count - 1 do
      TAdoDataset(l[i]).Connection := AdoConnection2;
    for I := 0 to l.Count - 1 do
      TAdoDataset(l[i]).Open;
   finally
     l.Free;
   end;
end;

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 23.03.13 12:18 
Leider eine Fehlermeldung: "Operator oder Semikolon fehlt"

ausblenden Delphi-Quelltext
1:
2:
for I := 0 to l.Count - 1 do
          DaMod1.AdoDataset1(l[i]).Connection := nil;

_________________
ut vires desint, tamen est laudanda voluntas
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Sa 23.03.13 13:40 
Zitat:

DaMod1.AdoDataset1(l[i]).Connection := nil;


Du hast ja die Adodatasets bereits in der Liste, was fehlt ist ein CAST auf TAdoDataset

ausblenden Delphi-Quelltext
1:
  TAdoDataset(l[i]).Connection := nil;					

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 23.03.13 14:00 
Hi, Bummi,

[delphi] for I := 0 to l.Count-1 do TAdoDataset.Connection := NIL;

Fehlermeldung:
[Pascal Fehler] BJS03.pas(298): E2233 Auf Eigenschaft 'Connection' kann hier nicht zugegriffen werden

LG, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Sa 23.03.13 14:10 
Du sollst ja auch L[i] casten nicht die Connectionproperty der Klasse beschreiben .....

L[i].Connection geht nicht, daher TAdoDataset(L[i]).Connection ...

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS

Für diesen Beitrag haben gedankt: D. Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 23.03.13 16:44 
Danke - dein Kommentar stimmt. :-))

LG, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 24.03.13 20:03 
Noch eine Nachfrage:

ich will mir die Einträge in der Liste ausgeben lassen, scheitere aber mit dem folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
// var meldung : string;

l := TList.Create;
      meldung := '';
      try
        for i := 0 to DaMod1.AdoConnection1.DataSetCount-1 do
        begin
          // if DaMod1.AdoConnection1.DataSets[i].Active then
          l.Add(DaMod1.AdoConnection1.DataSets[i]);
          //meldung := meldung + l.items[i] + #13;    // so geht es nicht!
        end;
        showmessage(meldung);
 
        .....

_________________
ut vires desint, tamen est laudanda voluntas
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 24.03.13 21:47 
- Nachträglich durch die Entwickler-Ecke gelöscht -
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 24.03.13 23:21 
Moin, Frühlinggsrolle,

leider ist die Ausgabe nicht sehr erhellend, etwa in der Art: @M

Bis zum Sommer :-))
LG, Det

_________________
ut vires desint, tamen est laudanda voluntas
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Mo 25.03.13 00:28 
Da es sich bei den Items in der Liste um CustomAdoDatasets handelt musst Du wieder casten und kannst dann alles ausgeben was ein CustomAdoDataset kennt, also z.B. Name ...

[delphi]
meldung := meldung + TCustomAdoDataset(l.items[i]).Name +#13#10;
[delphi]

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS

Für diesen Beitrag haben gedankt: D. Annies