开发者

How to count the number of updated row

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜