943,568 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 2026
  • VB.NET RSS
Feb 9th, 2008
0

Counting the records of a database

Expand Post »
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?

VB.NET Syntax (Toggle Plain Text)
  1. Dim ProdUserID As String = "samurai"
  2. Dim ProducaoSource As New SqlDataSource()
  3. ProducaoSource.ConnectionString = ConfigurationManager.ConnectionStrings("seaempiresdbConnectionString1").ToString()
  4. ProducaoSource.SelectCommandType = SqlDataSourceCommandType.Text
  5. ProducaoSource.SelectCommand = "SELECT * FROM Producao WHERE ProdUserID=UtilizadorID"
  6. Dim TotalLinhas As Integer = 0
  7. Try
  8. TotalLinhas = ProducaoSource.Select()
  9. Finally
  10. End Try

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

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
GonKas is offline Offline
2 posts
since Feb 2008
Feb 9th, 2008
0

Re: Counting the records of a database

Try:

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

This will give the number of rows that meet this criteria.
Reputation Points: 13
Solved Threads: 2
Light Poster
poguemahone is offline Offline
25 posts
since Aug 2007
Feb 9th, 2008
0

Re: Counting the records of a database

poguemahone already give the answer to get total records. but if it still redundant use DISTINCT to omitted redundant records.
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,137 posts
since Nov 2007
May 12th, 2008
0

Re: Counting the records of a database

Thanks people for your support!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
GonKas is offline Offline
2 posts
since Feb 2008
May 12th, 2008
0

Re: Counting the records of a database

you're Welcome
don't Forget to mark this thread solved...
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,137 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: make a program acept keystrokes even if it is not the active window?
Next Thread in VB.NET Forum Timeline: function in vb.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC