How to get no of records updated

  • drazen
  • Topic Author
  • Visitor
  • Visitor
12 years 4 months ago #532 by drazen
How to get no of records updated was created by drazen
Is there any way to get no of records updated/deleted when using CCommand.Open method (DBROWCOUNT)?
Eg, Oracle OLEDB provider always returns no of records, for SELECT, UPDATE, DELETE, etc.

Please Log in or Create an account to join the conversation.

More
12 years 4 months ago #533 by Moderator
There should be a separate method Execute with the parameter:
Code:
CCommand<CNoAccessor, CNoRowset> cmd; DBROWCOUNT* pRowsAffected; . . . cmd.Execute(. . ., pRowsAffected, . . .);
.

Please Log in or Create an account to join the conversation.

  • drazen
  • Topic Author
  • Visitor
  • Visitor
12 years 4 months ago #534 by drazen
Replied by drazen on topic Re: How to get no of records updated
cmd.Open calls ExecuteAndBind that calls Execute and RowsAffected is always -1 (from ICommand::Execute method).
Should I set some properties to get correct number of rows affected?

Please Log in or Create an account to join the conversation.

More
12 years 4 months ago #538 by Moderator
Here is fragment of code I used, and the number of affected rows was returned correctly:
Code:
#include <atldbcli.h> CDataSource dataSource; CSession session; HRESULT hr = dataSource.OpenFromInitializationString(CONN_STR); hr = session.Open(dataSource); // Start transaction hr = session.StartTransaction(); // update a record in contact table CCommand<CNoAccessor, CNoRowset> cmd; DBROWCOUNT rowsAffected; hr = cmd.Open(session, "UPDATE contact SET fname='test' WHERE contact_id=1", NULL, &rowsAffected, DBGUID_DBSQL, false); cmd.Close(); // delete records hr = cmd.Open(session, "DELETE FROM contact WHERE contact_id<>1", NULL, &rowsAffected, DBGUID_DBSQL, false); cmd.Close(); // Rollback transaction session.Abort();

What version of PGNP Provider are you using? Would you send sample code to reproduce the issue?

Please Log in or Create an account to join the conversation.

Time to create page: 0.134 seconds
Powered by Kunena Forum