RowsAffected: wrong return values with TUniSQL AND TUniQuery?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Krampus
Posts: 3
Joined: Fri 21 Feb 2014 12:23

RowsAffected: wrong return values with TUniSQL AND TUniQuery?

Post by Krampus » Fri 21 Feb 2014 18:54

hi,

I´m having troubles counting the affected rows of a simple SQL-statement.
while in ADODB one only has to call ADODBConn.Execute(sql, iAff), and basta
this seems to be a real problem with UniDAC... :?

- TUniConnection: cant do it at all! (you really should implement that :wink: )
- TUniSQL.RowsAffected: 0 (instead of 2)
- TUniQuery.RowsAffected: -1 (instead of 2)

so I tried both UniSQL and UniQuery - BOTH deliver wrong (and different) values?!?
debugging with dbMonitor-SQL-Pane shows the correct row-count!!
-----------------------------------------
UniDAC Version: 5.2.6, Delphi7
Server: MSSQL 2008RS2 (10.50.2500.0)
---------------------------
Delphi Code:
sSQL := 'UPDATE TestProject SET testZeit = GETDATE(), testMinuten = testMinuten + 1';
UniSQL := TUniQuery.Create(nil);
with UniSQL do begin
Connection := UniConn;
SQL.Text := sSQL;
end;
iAff := UniSQL.RowsAffected; result: -1, correct: 2
UniSQL.Free;

---------------------------------------------------
this is the table-definition, in case u want to reproduce
---------------------------------------------------
CREATE TABLE [TestProject](
[testID] [int] NOT NULL,
[testText] [varchar](50) COLLATE Latin1_General_CI_AS NULL,
[testDatum] [datetime] NULL,
[testZeit] [time](0) NULL,
[testMinuten] [int] NULL,
[testAdded] [smalldatetime] NOT NULL,
CONSTRAINT [PK_TestProject] PRIMARY KEY CLUSTERED
([testID] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]
GO
ALTER TABLE [TestProject] ADD CONSTRAINT [DF_TestProject_testAdded] DEFAULT (getdate()) FOR [testAdded]
GO

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: RowsAffected: wrong return values with TUniSQL AND TUniQuery?

Post by AlexP » Mon 24 Feb 2014 09:37

Hello,

There is no call for the execute method in the Delphi code you have provided, therefore you get RowsAffected = -1. If you call this method, you will get a correct value of RowsAffected

Post Reply