troubleshooting Question

getting results of sql command select count(*) from mytable where field1='test'

Avatar of wesapple
wesapple asked on
Visual Basic.NET
3 Comments1 Solution823 ViewsLast Modified:
I wanted to run the below code to get the count of records matching a certain criteria.  But I found out, then confirmed in .net help, that executenonquery returns -1 in this case.  How can I do this?  I don't need the row/rows themselves.  Just the count.

HitsCmd.CommandText = "SELECT COUNT(*) FROM mytable WHERE field='test'"
If HitsCmd.ExecuteNonQuery = 0 Then

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros