Autor Beitrag
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Mi 02.06.04 11:18 
Hi Leute,

Vorab: ich habe eine Access Datenbank unter Systemeinstellungen\Verwaltung\ODBC Datenquellen registriert. Nun verwende ich die ODBC Quelle als angabe für mein (ADODB.Connection).Open() (=DBConnectionString). Syntax scheint zwar in Ordnung zu sein, aber trotz der Tatsache das Einträge in der Tabelle stehen bekommen ich bei der 'SELECT * FROM MeinerTabelle' keine Records (RecordCount = -1) bzw Daten zurück.

Codeauszug:
ausblenden volle Höhe 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:
28:
29:
30:
31:
32:
33:
34:
  try
   if VarType(DBConnect) = varEmpty then
    if CoInitialize(NIL) = s_OK then DBConnect := CreateOLEObject('ADODB.Connection');
   DBConnect.Open(DBConnectionString);
  except
   result := -1;
  end;
  if result = 0 then
  try
  pReq := TReadRequest(ReadRequest.Items[0]);
   try
    if pReq.sCommandline1 <> '' then
    case UpperCase(GetDataValue(pReq.sCommandline1,SEPARATOR,0))[1] of
     'M' : MRecordSet := DBConnect.Execute(CreateSelectCommand(pReq.sCommandline1)); // SelectCommand=SELECT * FROM Tabelle
     'S' : SRecordSet := DBConnect.Execute(CreateSelectCommand(pReq.sCommandline1));
    end;
    if pReq.sCommandline2 <> '' then
     case UpperCase(GetDataValue(pReq.sCommandline2,SEPARATOR,0))[1] of
      'M' : MRecordSet := DBConnect.Execute(CreateSelectCommand(pReq.sCommandline2));
      'S' : SRecordSet := DBConnect.Execute(CreateSelectCommand(pReq.sCommandline2));
     end;
   except
    ErrStr := ErrStr+DBConnect.Errors[DBConnect.Errors.Count-1].Description+SEPARATOR;
   end;
   Ergebnis := TStringList.create;
   try
    if VarType(MRecordSet) <> varEmpty then
     if MRecordSet.RecordCount > 0 then begin
        Ergebnis.Add(MRecordSet.GetString(StringClipString,-1,SEPARATOR,LineBreaker));
    end;
    if VarType(SRecordSet) <> varEmpty then
     if SRecordSet.RecordCount > 0 then begin
        Ergebnis.Add(SRecordSet.GetString(StringClipString,-1,SEPARATOR,LineBreaker));
    end;

_________________
mfg
Tana´Ri
Tana´Ri Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Do 03.06.04 09:56 
Hi Leute,

es lag am RecordCount, das Stand immer auf -1.
Die EOF Variante funktioniert aber korrekt.

_________________
mfg
Tana´Ri
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Do 03.06.04 10:35 
Hallo,

wenn Du in der ADOConnection die CursorLocation auf clUseServer stellst, was bei Access-DB's zu empfehlen ist, dürfte auch RecordCount das gewünschte Ergebnis liefern.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)