Zum Inhalt springen

Empfohlene Beiträge

Geschrieben

Hi,

ich habe eine Access Tabelle mit 5 Datensätzen. Mein Programm soll diese auslesen

und in Variablen speichern, komischerweise wird immer nur ein Datensatz im

Recordset gespeichert und ich habe keine Ahnung warum, ihr vieleicht?


HRESULT Dokus()
{
char sqltemp[500],
szFehler[150];
CString strValue;
CRecordset Record(&g_.Datenquelle);

sprintf (sqltemp,"SELECT * FROM %s",Info.strDoku);

try
{
Record.Open(CRecordset::snapshot,sqltemp,CRecordset::none);
}
catch(CDBException dbex)
{
strcpy(szFehler,"F#Ein unbekannter Fehler ist aufgetreten.");
send(g_.ClientSocket,szFehler,strlen(szFehler),NULL);
dbex.ReportError();
return -1;
}

try
{
Info.iAnzahlDokus = Record.GetRecordCount();
_CrtDbgReport(_CRT_ASSERT,"fth",4,"fgngzj","anz = %i",Info.iAnzahlDokus);
if (Info.iAnzahlDokus > 0)
{
Info.strDokuname = new CString[Info.iAnzahlDokus];
Info.strDokupfad = new CString[Info.iAnzahlDokus];

//Record.MoveFirst();
for (int i=0; i<Info.iAnzahlDokus; i++)
{
Record.GetFieldValue(1,Info.strDokuname[i]);
Record.GetFieldValue(2,Info.strDokupfad[i]);
if (i < Info.iAnzahlDokus-1)
Record.MoveNext();
}
Info.bDokus = true;
}
return 1;
}
catch(CDBException dbex)
{
strcpy(szFehler,"F#Ein unbekannter Fehler ist aufgetreten.");
send(g_.ClientSocket,szFehler,strlen(szFehler),NULL);
dbex.ReportError();
return -1;
}
return 0;
}
[/PHP]

Gruß

Guybrush

Geschrieben

wie kann es bitteschön sein, dass wenn ich anstatt:

Info.iAnzahlDokus = Record.GetRecordCount();

schreibe:

Info.iAnzahlDokus = 5;

Das dann alle 5 Datensätze ausgelsen werden? Wieso liefert GetRecordCount()

die falsche Anzahl?

:confused: :confused: :confused:

Geschrieben

Ach Guybrush....du weisst doch...Brille aufsetzen und MSDN lesen :D

Caution   The record count is maintained as a “high water mark†— the 
highest-numbered record yet seen as the user moves through the records. The total
number of records is only known after the user has moved beyond the last record.
For performance reasons, the count is not updated when you call MoveLast. To count
the records yourself, call MoveNext repeatedly until IsEOF returns nonzero. Adding a
record via CRecordset:AddNew and Update increases the count; deleting a record via
CRecordset::Delete decreases the count.
[/PHP]

Goos

Geschrieben

Naja fuer deine Zwecke braucht man das GetRecordCount() auf jeden Fall eher nicht so. Ich kenne aber ausser dir auch niemandend der alle Datensaetze auf einmal auslesen will, da dass ja in der Regel eher elfundneunzigtausend Datensaetze sind und nicht nur fuenf wie in deinem Fall.

...ach und das mit der Brille: Ich hab irgendwann mal gehoert, dass jeder zweite ne Brille hat....da ich aber nun mal ausser der Sonnenbrille keine eigene besitze....usw

:D

Goos

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...