Solved

Delphi: Get the number of affected Rows of an Update

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
APK file name 7 63
delphi prevent click fast 2 165
FMX enumerated colours 2 72
Delphi : could not find program, '...exe' 2 116
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

13 Experts available now in Live!

Get 1:1 Help Now