im useless
im useless

Reputation: 7451

Counting rows with a SqlDataAdapter

I have a problem in my code. I want to get the row count from my SqlDataAdapter if there are any rows.

Upvotes: 1

Views: 15046

Answers (2)

Hogan
Hogan

Reputation: 70513

Maybe try dt.Rows.Count since that is a table and has rows.

Upvotes: 4

BrokenGlass
BrokenGlass

Reputation: 160852

You were doing an assignment instead of a comparison, you have to use == :

if (dt.Rows.Count == 0 )
{
    // code here
}

Upvotes: 4

Related Questions