954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Counting the records of a database

Hi there!

I've a problem...want to return the total number of rows affected by the statement "SELECT * FROM Producao WHERE ProdUserID=UtilizadorID" can anybody give a look to the code below?

Dim ProdUserID As String = "samurai"
        Dim ProducaoSource As New SqlDataSource()
        ProducaoSource.ConnectionString = ConfigurationManager.ConnectionStrings("seaempiresdbConnectionString1").ToString()
        ProducaoSource.SelectCommandType = SqlDataSourceCommandType.Text
        ProducaoSource.SelectCommand = "SELECT * FROM Producao WHERE ProdUserID=UtilizadorID"
        Dim TotalLinhas As Integer = 0
        Try
            TotalLinhas = ProducaoSource.Select()
        Finally
        End Try


The only thing I want is that the var TotalLinhas remains with the number of records...in this case 7 (seven).

Thanks

GonKas
Newbie Poster
2 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

Try:

SELECT COUNT(*) FROM Producao WHERE ProdUserID=UtilizadorID.

This will give the number of rows that meet this criteria.

poguemahone
Light Poster
25 posts since Aug 2007
Reputation Points: 13
Solved Threads: 2
 

poguemahone already give the answer to get total records. but if it still redundant use DISTINCT to omitted redundant records.

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

Thanks people for your support!

GonKas
Newbie Poster
2 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

you're Welcome :)
don't Forget to mark this thread solved...

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You