 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alan T Guest
|
Posted: Mon Oct 30, 2006 5:18 am Post subject: Access violation in the Query.SQL.Add statement |
|
|
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
|
Posted: Mon Oct 30, 2006 5:35 am Post subject: Re: Access violation in the Query.SQL.Add statement |
|
|
"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
|
Posted: Mon Oct 30, 2006 7:25 am Post subject: Re: Access violation in the Query.SQL.Add statement |
|
|
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 |
|
 |
|
|
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
|
|