Home    Contact Us    Sitemap    
Articles    Help/Support    Directory Listing    Forum
User Name:
Password:
 
     
Forgot Password       Register here for free     
Article: User Rating Technique


Did you find this article useful?
Request to exchange this article

Report this article


USER RATING TECHNIQUE

Author: Imran

User Rating Technique

First of all create a table which have value RatingID and your content id like in my logic SiteID like Comments then create a stored procedure like

CREATE PROCEDURE Q_GetRatingInfo(@SiteID int) AS

SELECT

(SELECT COUNT(*) FROM Comments WHERE SiteID = @SiteID AND RatingID = 1) as Rating1Count,

(SELECT COUNT(*) FROM Comments WHERE SiteID = @SiteID AND RatingID = 2) as Rating2Count,

(SELECT COUNT(*) FROM Comments WHERE SiteID = @SiteID AND RatingID = 3) as Rating3Count,

(SELECT COUNT(*) FROM Comments WHERE SiteID = @SiteID AND RatingID = 4) as Rating4Count,

(SELECT COUNT(*) FROM Comments WHERE SiteID = @SiteID AND RatingID = 5) as Rating5Count,

ISNULL((SELECT AVG(CONVERT(float, RatingID)) FROM Comments WHERE SiteID = @SiteID), 0.0) as AvgRating,

(SELECT COUNT(*) FROM Comments WHERE SiteID = @SiteID) as RatingCount

GO



then create a function AvgRating

Public Function AvgRating(ByVal SiteID As Integer) As Decimal

Dim con As New SqlConnection(myConStr)
con.Open()

Dim avgrate As Decimal

Dim myCommand As SqlCommandmyCommand = New SqlCommand("Q_GetRatingInfo", con)
myCommand.CommandType = CommandType.StoredProcedure

myCommand.Parameters.AddWithValue("@SiteID", SiteID)

Dim reader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
If reader.Read Then

avgrate = Convert.ToSingle(reader("AvgRating"))
End If

con.Close()

Return avgrate
End Function

User Rating Technique



Did you find this article useful?
Request to exchange this article

Report this article

Note: RankRanker claims no responsibility for the accuracy of information in articles.

Reader Comments

DatePosted ByComment
13/2/2008 khan good realy usefull
Post Your Comment

Please keep your comments relevant to this article entry: inappropriate or purely promotional comments may be removed. Email addresses are never displayed, but they are required to confirm your comments.
Your Name(required):*
 
Your email address (required, will not be shown to the public): *
   
Your Site's URL (optional)
 
Do you want us to remember your personal information for next time?
Add your Comments: *
 







© Copyrights 2007, RankRanker.com. | Privacy policy | Terms | Contact Us
Free link building directory | Free 1 one way links | 2 two way links exchange | Reciprocal links | BackLinks | link popularity
Design and Developed by SUNZTECH.COM