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!

Understanding an error in my code

Status
Not open for further replies.

minckle

Programmer
Mar 17, 2004
142
0
0
GB
I have written a piece of software in Delhpi v5 using MySQL as a backend database.

Im writing errors to a standard text file. 99% of the time the app works fine, but every now and then i get the following error

Error:
Time - 05/01/2006 18:00:24,
Procedure when errored - GetNumberOfInMsgs :
Error Msg - Access violation at address 4BDECBAA
in module 'IDAPI32.DLL'. Read of
address CCCCCCDC

I realise that the 'IDAPI32.DLL' is to do with the BDE. Does this type of error mean anything to anyone?? is it something obvious that im doing wrong??

Any help would be appreciated !!

Thanks
 

Without seeing the actual code in GetNumberOfInMsgs, the "Access violation at address..." usually means you have exceeded the number of items in an array or a list. Perhaps you are trying to access SomeList[0] when the list is empty or doesn't exist.

 
Hi, I can give you the code, but dont know how much it will help as bits of it reply on other others of the app, But the code is below if you have any obvioius ideas.



procedure GetNumberOfInMsgs;
var
qry: TQuery;
qry1: TQuery;
sMsgCount: string;
begin
// select -> insert query
qry := TQuery.Create(dmQueue);
qry1 := TQuery.Create(dmQueue);
try
qry.DatabaseName := 'itextit';
qry1.DatabaseName := 'itextit';
if (dmRoot.SessionName <> '') then
begin
qry.SessionName := dmRoot.SessionName;
qry1.SessionName := dmRoot.SessionName;
end;
qry.SQL.Add('select count(id) as count from in_q');
qry.SQL.Add('where del=''U''');
qry.Open;

if (not qry.Eof) then
begin
sMsgCount := qry.fieldByName('count').asString;
qry1.SQL.Clear;
qry1.SQL.Add('UPDATE count_in_msgs');
qry1.SQL.Add('set count = ''' + sMsgCount + '''');
qry1.SQL.Add('WHERE id = 1');
qry1.ExecSQL;
end
else
begin
qry1.SQL.Clear;
qry1.SQL.Add('UPDATE count_in_msgs');
qry1.SQL.Add('set count = 0');
qry1.SQL.Add('WHERE id = 1');
qry1.ExecSQL;
end;

except
on E:EDBEngineError do
begin
HandleEDBEngineError('GetNumberOfInMsgs', E);
end;
on E:Exception do
begin
HandleException('GetNumberOfInMsgs', E);
end;
end;
qry.Free;
qry1.Free;
end;
 
Not sure, but since "count" is a reserved word in SQL, perhaps you should try something like this:
Code:
    qry.SQL.Add('select count(id) as [b]Mycount[/b] from in_q');
    qry.SQL.Add('where del=''U''');
    qry.Open;

    if (not qry.Eof) then
    begin
        sMsgCount := qry.fieldByName('[b]Mycount[/b]').asString;
You should also wrap the code in a try...finally so that your .Free statements will be executed whether or not there is an error.
 

Add data to your error log. Add the value of sMsgCount.

Add a trace string varialble like:

Code:
var
  Step : AnsiString;
begin
  ...
if (not qry.Eof) then
    begin
        sMsgCount := qry.fieldByName('count').asString;
        qry1.SQL.Clear;
        qry1.SQL.Add('UPDATE count_in_msgs');
        qry1.SQL.Add('set count = ''' + sMsgCount + '''');
        qry1.SQL.Add('WHERE id = 1');
        [b]Step := 'Executing query 1';[/b] 
        qry1.ExecSQL;
    end
    else
    begin
        qry1.SQL.Clear;
        qry1.SQL.Add('UPDATE count_in_msgs');
        qry1.SQL.Add('set count = 0');
        qry1.SQL.Add('WHERE id = 1');
        [b]Step := 'Executing query 2';[/b] 
        qry1.ExecSQL;
    end;

and dump it to your error log to.

Try to pinpoint the action where the exception is produced and the conditions; I think you are dealing with some obnoxious "feature" in the Borland or driver's code.

If I'm right, to get a workaround you need to gatter the most info you can.

HTH.
buho (A).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top