开发者

How to count the number of updated row

开发者 https://www.devze.com 2023-03-16 21:31 出处:网络
I have an access database, and I do this query : OleDatabase OleDB = new OleDatabase(\"MyDatabase\"); string comando = \"UPDATE ANAGRAFICA SET DENOMINAZIONE=\'\" + aziendaValue[\"nome\"] + \"\', INDI

I have an access database, and I do this query :

OleDatabase OleDB = new OleDatabase("MyDatabase");
string comando = "UPDATE ANAGRAFICA SET DENOMINAZIONE='" + aziendaValue["nome"] + "', INDIRIZZO='" + aziendaValue["indirizzo"] + "' WHERE PIVA='" + aziendaValue["piva"] + "'";
OleDB.oleComando(comando);

How can I check how many rows (0 to n) the quer开发者_如何学JAVAy update?


I'm not 100% on this since I haven't touched MS Access in a while, but I'm pretty sure that with ExecuteNonQuery you get the number of updated records, for example:

OleDbCommand command = new OleDbCommand("UPDATE SomeTable SET SomeColumn='SomeValue'", SomeConnection);
int updated_records_count = command.ExecuteNonQuery();


You should use OleDbCommand.ExecuteNonQuery. It returns the number of affected rows.


First thing you can do is: "SELECT COUNT(*) FROM ANAGRAFICA WHERE PIVA="+aziendaValue["piva"]. It takes a query more, but it should actually work and if you don't have problems with efficiency doing it is safe for sure!

0

精彩评论

暂无评论...
验证码 换一张
取 消