colttaylor
Programmer
I'm using Microsoft's data-access application block and I would like a faster (more resource friendly) method of getting the count of active records in a table.
Here is a rough sketch of what I am currently doing...
Public Function get_company_count() As Integer
get_company_count = 0
Dim cmd As String = "count from tbl_companies where cmb_status = A"
Dim loc_companies As DataSet = SqlHelper.ExecuteDataset(Settings.SQLConnectStrUser, System.Data.CommandType.Text, cmd)
get_company_count = companies.Tables("tbl_companies").Rows.Count
End Function
What I would like to do is use Microsoft SQL's COUNT function, i.e. SELECT COUNT(CMP_ID)... but I don't know how to get just an integer value out of the sqlhelper class. Anybody have any ideas?
thanks in advance!
Colt
If it's stupid but it works, it isn't stupid
Here is a rough sketch of what I am currently doing...
Public Function get_company_count() As Integer
get_company_count = 0
Dim cmd As String = "count from tbl_companies where cmb_status = A"
Dim loc_companies As DataSet = SqlHelper.ExecuteDataset(Settings.SQLConnectStrUser, System.Data.CommandType.Text, cmd)
get_company_count = companies.Tables("tbl_companies").Rows.Count
End Function
What I would like to do is use Microsoft SQL's COUNT function, i.e. SELECT COUNT(CMP_ID)... but I don't know how to get just an integer value out of the sqlhelper class. Anybody have any ideas?
thanks in advance!
Colt
If it's stupid but it works, it isn't stupid