Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class ScoreEval
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConn As String = WebConfigurationManager.ConnectionStrings("Library").ConnectionString
Dim Conn As New SqlConnection(strConn)
Dim dtAdapter As SqlDataAdapter
Dim dt As New DataTable
Dim sql1 As String
sql1 = "SELECT SUM(poll_ans) As score , COUNT(poll_ans) As qqq FROM poll_ans WHERE adviso = '" & Session("uname") & "'"
dtAdapter = New SqlDataAdapter(sql1, Conn)
dtAdapter.Fill(dt)
Dim Score As Integer
Dim Ques As Integer
Ques = IIf(IsDBNull(dt.Rows(0)("qqq")), String.Empty, dt.Rows(0)("qqq"))
Score = IIf(IsDBNull(dt.Rows(0)("score")), String.Empty, dt.Rows(0)("score"))
sql1 = "SELECT COUNT(DISTINCT login_id) AS ddss FROM poll_ans WHERE adviso = '" & Session("uname") & "'"
dtAdapter = New SqlDataAdapter(sql1, Conn)
dtAdapter.Fill(dt)
Dim Count As Integer
MsgBox(sql1)
Count = IIf(IsDBNull(dt.Rows(0)("ddss")), String.Empty, dt.Rows(0)("ddss"))
Dim sumscore As Double
sumscore = Score / (Ques * 5 * Count) * 100
lblScore.Text = sumscore & "%"
lblStudent.Text = Count
End Sub
End Class
Dim dtAdapter As SqlDataAdapter
Dim ds As New DataSet
Dim sql1 As String
sql1 = "SELECT COUNT(DISTINCT login_id) AS ddss FROM poll_ans WHERE adviso = '" & Session("uname") & "'"
dtAdapter = New SqlDataAdapter(sql1, Conn)
dtAdapter.Fill(ds)
' อ้าง table ก็ใช้ ds.Table(0)
ลองดูก่อนว่ามันติดตรงไหนครับ พอดียังไม่ได้เอา code ไป run ดูครับ