muhammad.ibraheem 0 Newbie Poster
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration

Partial Class books
    Inherits System.Web.UI.Page
    Dim con As New SqlConnection

    Dim cmd As New SqlCommand



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            BindRatingControl()
        End If
    End Sub
    Protected Sub RatingControlChanged(ByVal sender As Object, ByVal e As AjaxControlToolkit.RatingEventArgs)
        con.ConnectionString = "Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\library.mdf;Integrated Security=True;Connect Timeout=30"



        con.Open()
        Dim cmd As New SqlCommand("insert into RatingDetails(Rate)values(@Rating)", con)
        cmd.Parameters.AddWithValue("@Rating", RatingControl.CurrentRating)
        cmd.ExecuteNonQuery()
        con.Close()
        BindRatingControl()
    End Sub
    Protected Sub BindRatingControl()
        Dim total As Integer = 0
        Dim dt As New DataTable()
        con.ConnectionString = "Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\library.mdf;Integrated Security=True;Connect Timeout=30"

        con.Open()
        Dim cmd As New SqlCommand("Select Rate from RatingDetail", con)
        Dim da As New SqlDataAdapter(cmd)
        da.Fill(dt)
        If dt.Rows.Count > 0 Then
            For i As Integer = 0 To dt.Rows.Count - 1
                total += Convert.ToInt32(dt.Rows(i)(0).ToString())
            Next
            Dim average As Integer = total \ (dt.Rows.Count)
            RatingControl.CurrentRating = average
            lbltxt.Text = dt.Rows.Count & "user(s) have rated this article"
        End If
    End Sub

I am getting error lbltext and Rating Control are not accessible it may be due to protection level