Solved

Delphi: Get the number of affected Rows of an Update

Posted on 2004-08-31
2
2,198 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 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now