For each line of a CSV file, my application needs to call a method which reads in each variables and writes some of them to a table using a GetDataItem method. e.g.
Var
Item: String;
Tmp: String;
Rdate: String;
TmpDateTime: TDateTime;
begin
Table1.Append'
Tmp := GetDataItem(Data, Item); {Ignore}
Tmp := GetDataItem(Data, Item); {Ignore}
Tmp := GetDataItem(Data, Item); {Members ID}
Table1.FieldByName('Member ID').AsString := UpperCase(Tmp);
TmpDateTime := StrToDateTime(etDataItem(Data, Item));
Table1.FieldByName('Arrival Date').AsString := FormatDateTime('dd/mm/yyyy',TmpDateTime);
Table1.FieldByName('Arrival Time').AsString := FormatDateTime('hh:mm:ss',TmpDateTime);
...
Table1.Post;
This works fine except I also need to generate a ReverseDate from the DateTime stamp in the format yyyymmdd. However any attempt to use the timestamp variable again seems to throw an exception e.g.
RDate := FormatDateTime('yyyy',TmpDateTime) + FormatDateTime('mm',TmpDateTime) + FormatDateTime('dd',TmpDateTime);
or
RDate := FormatDateTime('yyyymmdd',TmpDateTime);
I've tried duplicating the DateTime variable and working on that instead, or splitting a DateTime String, but it's as if any further manipulation of throws an exception when run.
EDIT: Apologies, On my XP machine I now get the exception:
EAccessViolation in the module 'ImpWintacs.exe' at 000749DA. Access violation at address "000749DA" in module 'ImpWintacs.exe'. Read of address 00C1FDF8.
Thanks
The method I was using to read the next variable from the CSV, read the chars up until the next comma. The last variable in the CSV was not followed by a comma. As I didn't need the last variable anyway I just chose not to read it.