Hei,
I have an Access database with a querry containing 40,000 rows.
When I use "SELECT (*) COUNT FROM Querr" in ExecuteScalar, I get only about half of the rows. However, whem I copy the contents of the querry to a Table, a get the full 40,000 number of rows.
Any suggestions?
Best regards,
Tom

How are you doing the select? any chance you're getting every other row?

How are you doing the select? any chance you're getting every other row?

This is the code:

OleDbCommand test = conn.CreateCommand();
test.CommandText=
"SELECT COUNT(*) FROM expws3";
conn.Open();
int antall = (int)test.ExecuteScalar();

in which expws3 is the Access querry.

The exact number of rows is 43031 while I get only 24005 with this code.
I will try to use the same SQL statement that Access uses to build the Querry.
However, even if that works, it would be interesting to know what may cause this
difference.

Out of interest (not that it should make a difference) do you get the same result if instead of int you use Int32?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.