How do I get the results back from an SQL COUNT() operation in .Net. For example a query formulated something like this: SELECT COUNT(*) AS Expr1 FROM ChannelConfiguration AS X Many thanks.
Hello Andrew, cmd.CommandText = "SELECT COUNT(*) FROM dbo.region"; Int32 count = (Int32) cmd.ExecuteScalar(); AC> How do I get the results back from an SQL COUNT() operation in .Net. AC> For example a query formulated something like this: AC> AC> SELECT COUNT(*) AS Expr1 AC> FROM ChannelConfiguration AS X AC> Many thanks. --- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour "At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche
Thanks. It was that ExecuteScalar() method that I had not used before and was the 'silver bullet'. - Andrew "Michael Nemtsev" wrote in message news:9cc1c86375a3f8c7ef408862eab3@msnews.microsoft.com... > Hello Andrew, > > cmd.CommandText = "SELECT COUNT(*) FROM dbo.region"; > Int32 count = (Int32) cmd.ExecuteScalar(); > > AC> How do I get the results back from an SQL COUNT() operation in .Net. > AC> For example a query formulated something like this: > AC> AC> SELECT COUNT(*) AS Expr1 > AC> FROM ChannelConfiguration AS X > AC> Many thanks. > > --- > WBR, > Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour > > "At times one remains faithful to a cause only because its opponents do > not cease to be insipid." (c) Friedrich Nietzsche > >