Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delphi: Get the number of affected Rows of an Update

Posted on 2004-08-31
2
Medium Priority
?
2,988 Views
Last Modified: 2010-04-05
Hi all !
Using an Query-Object in Delphi 5, I want to get back the number of affected rows of an Update. How to do this.
I read about the "returning"-string but how to use it ?
Delphi:
query1.sql := 'update TABLE set id = 3 where port = 123';
query1.ExecSQL;
Showmessage(  [affected rows]  );
Thank you ...


0
Comment
Question by:delphistor
2 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 375 total points
ID: 11940209
just lookup the rowsAffected-property after execSQL like

query1.ExecSQL;
Showmessage(inttostr(query1.rowsaffected));

from delphi help:

----------------------
Returns the number of rows operated upon by the latest query execution.

Delphi syntax:

property RowsAffected: Integer;

Description

Inspect RowsAffected to determine how many rows were updated or deleted by the last query operation. If no rows were updated or deleted, RowsAffected has a value of zero. RowsAffected will have a value of –1 if the execution of the SQL statement could not be executed due to an error condition. This latter situation would typically follow the raising of an exception.
---------------------

hope this helps

meikl ;-)

0
 

Author Comment

by:delphistor
ID: 11940614
Thank you meikl - it works !
A simple but effective solution !!!
delphistor....
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question