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

16,549

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

Share:
16,549
Ajay_Kumar
Author by

Ajay_Kumar

Updated on July 18, 2022

Comments

  • Ajay_Kumar
    Ajay_Kumar almost 2 years

    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.