0
votes

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

1
What is the exception thrown? - ain
"throws an exception when run" is absolutely meaningless without the exception type and error message. It's like saying "My computer doesn't work. How can I fix it?" - gee, if it's a USB cable the fix is a lot easier than if the problem is a failed HDD or blown capacitor. When you have an error or exception, give the Exact error code and error message, including any memory addresses. If you want help, the easier you make it to provide it the quicker it will get to you to help solve the problem. - Ken White
My apologies, I'm new to Delphi and in this case didn't know how to print the exception. It now works fine on the Win2000 PC I compiled on but not the my other XP PC, with identical CSV and database files. I've included the latest exception as an Edit but here it is: EAccessViolation in the module 'ImpWintacs.exe' at 000749DA. Access violation at address "000749DA" in module 'ImpWintacs.exe'. Read of address 00C1FDF8. - notidaho

1 Answers

0
votes

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.