Counting the records of a database

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 2
Reputation: GonKas is an unknown quantity at this point 
Solved Threads: 0
GonKas GonKas is offline Offline
Newbie Poster

Counting the records of a database

 
0
  #1
Feb 9th, 2008
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?

  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 25
Reputation: poguemahone is an unknown quantity at this point 
Solved Threads: 2
poguemahone's Avatar
poguemahone poguemahone is offline Offline
Light Poster

Re: Counting the records of a database

 
0
  #2
Feb 9th, 2008
Try:

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

This will give the number of rows that meet this criteria.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Counting the records of a database

 
0
  #3
Feb 9th, 2008
poguemahone already give the answer to get total records. but if it still redundant use DISTINCT to omitted redundant records.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 2
Reputation: GonKas is an unknown quantity at this point 
Solved Threads: 0
GonKas GonKas is offline Offline
Newbie Poster

Re: Counting the records of a database

 
0
  #4
May 12th, 2008
Thanks people for your support!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Counting the records of a database

 
0
  #5
May 12th, 2008
you're Welcome
don't Forget to mark this thread solved...
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC