Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to count the total number of row in oledbconnection in c#.net

Tags:

c#

ado.net

oledb

how to count the total number of row in oledbconnection in c#.net

I want to count how many rows are present in my table.

                string dataReader = "SELECT count(*) from `Email_account_list`";
                OleDbCommand command_reader = new OleDbCommand(dataReader, myConnection);
                OleDbDataReader row_reader = command_reader.ExecuteReader();

What function i will write to fetch total number of rows present in table.

like image 334
Ajay_Kumar Avatar asked Oct 30 '25 02:10

Ajay_Kumar


1 Answers

A SELECT COUNT(*) statetment is a special (SELECT) statement in that you should not use ExecuteReader() but instead use int rowCount = (int) command.ExecuteScalar();

like image 53
Henk Holterman Avatar answered Nov 01 '25 17:11

Henk Holterman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!