Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process one record then access violation..

Status
Not open for further replies.

corsair2

IS-IT--Management
Feb 21, 2001
55
0
0
GB
Hi all,

Have the following piece of innocuous code which works fine when processing the first record then throws up access violations on the second - any ideas?

if (ODS2.FieldValues['Hist_Status']='Started') then
ActiveFlg:= True
else
ActiveFlg:= False;

If I insert a break at the first line and step through the code the following hint appears if the cursor is placed over the 'then' -

'Access violation at 40002269 accessing 3F43B8B3'

followed by an error box with the following message -

'access violation at 0x77f7d9f2: write of address 0x00030fc0'

I'm not writing anything - just reading!!

Please help - everything else works fine...
 
I've never used FieldValues, wouldn't you be better using FieldByName? Changing it to use FieldByName('').As... should speed it up as it won't need to use variants for the values.

Doesn't solve your problems but may help in understanding why.

 
if your Hist_status field contains null values, this will be the reason for AV's. use fieldbyname like lou said...

--------------------------------------
What You See Is What You Get
 
Thanks Guys,

Have changed to "FieldByName('Hist_Status').AsString" and confirmed that the fields do not contain Nulls but still get the AV.
In particular, what I don't understand is the 'write of address 0x00030f1c' message as I thought I was only reading...
So, the only other thing I can think of is the post to the flag, but how the heck can a simple True/False flag set off an AV?

Regards
 
Hi again,

have tried this also with FldVal declared as a type string -

FldVal:= OracleDataSet2.FieldByName('Hist_Status').AsString;
if (FldVal='Started') then
ActiveFlg:= True
else
ActiveFlg:= False;

The AV occurs as soon as the first line is actioned.
 
Why are you referencing the dataset instead of the underlying query?
Code:
  If qryJurorInformation.FieldbyName('LASTNAME').asString = 'SMITH' then
    ActiveFlg := True
  else
    ActiveFlg := False;

Leslie
 
I'm using Direct Oracle Access components, in this instance the OracleDataSet. Hence the reference to the returned dataset.
 
corsair2,
"In particular, what I don't understand is the 'write of address 0x00030f1c' message as I thought I was only reading..."

If I'm not wrong, the message is not saying error on writing the data to the dataset. To run a process, system will keep on writing and reading bits to the memory location or registry. The error was occur during the system try to write those bits to the registry.
 
corsair2,
The system face the AV on which statement?? Is it the if checking statement? if yes, then you check whether your dataset was still open, or whether you dataset had lost.....
used watch to check it out.
 
It may be a simple thing but how have you defined ActiveFlg and where?

Scotto the Unwise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top