BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Access violation in the Query.SQL.Add statement

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Alan T
Guest





PostPosted: Mon Oct 30, 2006 5:18 am    Post subject: Access violation in the Query.SQL.Add statement Reply with quote



with Query1 do
try
Close;
SQL.Clear;
SQL.Add('DELETE FROM ' + aTable1 +
' WHERE id = ' + IntToStr(fId));
Execute;
except on e:exception do
Showmessage(e.Message);
end;

I got the exception in the SQL.Add statement:
"Access violation at address 006F2D4A in module 'myApp.exe'. Read of address
00000004"

Any idea ?
Back to top
John Herbster
Guest





PostPosted: Mon Oct 30, 2006 5:35 am    Post subject: Re: Access violation in the Query.SQL.Add statement Reply with quote



"Alan T" <alanpltseNOSPAM (AT) yahoo (DOT) com.au> wrote
Quote:
with Query1 do
try
Close;
SQL.Clear;
SQL.Add('DELETE FROM ' + aTable1 +
' WHERE id = ' + IntToStr(fId));
Execute;
except on e:exception do
Showmessage(e.Message);
end;

I got the exception in the SQL.Add statement: ...
Any idea ?

Sure! Alan, you need to divide to conquer.
In other words split the problem statement up into
s := 'DELETE FROM ' + aTable1 +
' WHERE id = ' + IntToStr(fId);
SQL.Add(s);
where s is a string variable and try that.
Rgds, JohnH
Back to top
Steve Troxell
Guest





PostPosted: Mon Oct 30, 2006 7:25 am    Post subject: Re: Access violation in the Query.SQL.Add statement Reply with quote



John Herbster wrote:
Quote:
"Alan T" <alanpltseNOSPAM (AT) yahoo (DOT) com.au> wrote
with Query1 do
try
Close;
SQL.Clear;
SQL.Add('DELETE FROM ' + aTable1 +
' WHERE id = ' + IntToStr(fId));
Execute;
except on e:exception do
Showmessage(e.Message);
end;

I got the exception in the SQL.Add statement: ...
Any idea ?

Sure! Alan, you need to divide to conquer.
In other words split the problem statement up into
s := 'DELETE FROM ' + aTable1 +
' WHERE id = ' + IntToStr(fId);
SQL.Add(s);
where s is a string variable and try that.
Rgds, JohnH

I suspect the problem is in referencing either aTable1 or fId, so I'd
divide and conquer like this:

s := 'DELETE FROM ' + aTable1;
s := s + ' WHERE id = ' + IntToStr(fId);
SQL.Add(s);

Actually, I'd just breakpoint on the Add and examine aTable1 and fId in
the debugger. One of them will most likely throw an exception when
trying to evaluate its value.

If this code is a class method and fId is the first reference to a class
member, then I'd suspect the class instance is nil.

Steve Troxell
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.