Solved

Delphi: Get the number of affected Rows of an Update

Posted on 2004-08-31
2
2,638 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month5 days, 8 hours left to enroll

627 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