What is the difference between ExecuteScalar, ExecuteReader and ExecuteNonQuery?

ExecuteReader:

Used for any result which returns multiple rows / columns. Mostly used for select statements.

ExecuteScalar:

Used for any result which return only single value. if it returns more that 1 row/column, then the result is the first column of the first row.

Mostly used in aggregate functions like sum, avg etc.

ExecuteNonQuery:

Used in queries which does not return any data. Mostly used with Delete, Update, Insert queries.

Comments

Popular posts from this blog

GRANDING UTime Master - IDOR (CVE-2023-45393)

GRANDING UTime Master - Stored XSS (CVE-2023-45391)

Ericsson BSCS iX R18 Billing & Rating (ADMX, MX) - Stored XSS (CVE-2020-29144, CVE-2020-29145)