黑色火焰LQ 黑色火焰LQ
关注数: 0 粉丝数: 5 发帖数: 61 关注贴吧数: 13
帮忙查找错误,谢谢 帮忙查找一下下面的错误Public Class Scores Inherits System.Web.UI.Page#Region " Web 窗体设计器生成的代码 " '该调用是 Web 窗体设计器所必需的。 Private Sub InitializeComponent() End Sub Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel Protected WithEvents rblClass As System.Web.UI.WebControls.RadioButtonList Protected WithEvents ckbStudents As System.Web.UI.WebControls.CheckBoxList Protected WithEvents dltScores As System.Web.UI.WebControls.DataList '注意: 以下占位符声明是 Web 窗体设计器所必需的。 '不要删除或移动它。 Private designerPlaceholderDeclaration As System.Object Private Sub BindList() Dim strWhere As String Dim itm As ListItem For Each itm In ckbStudents.Items If itm.Selected Then If strWhere <> String.Empty Then strWhere &= "OR" End If strWhere &= "tblStudents.StudentID=" & itm.Value & "" End If Next If strWhere <> String.Empty Then dltScores.Visible = True Dim conn As New System.Data.SqlClient.SqlConnection("server=LIUQI;integrated security=SSPI;initial catalog=StudentMS") Dim cmd As New System.Data.SqlClient.SqlCommand cmd.Connection = conn cmd.CommandText = "SELECT Name AS 姓名,Average AS 平均成绩,Total AS 总分 FROM tblStudents JOIN tblScores ON tblStudents.StudentsID=tblScores.StudentsID WHERE" & strWhere conn.Open() Dim dr As System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader dltScores.DataSource = dr dltScores.DataBind() dr.Close() conn.Close() Else dltScores.Visible = False End If End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: 此方法调用是 Web 窗体设计器所必需的 '不要使用代码编辑器修改它。 InitializeComponent() End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Me.IsPostBack Then Dim conn As New System.Data.SqlClient.SqlConnection("server=LIUQI;integrated security=SSPI;initial catalog=StudentMS") Dim cmd As New System.Data.SqlClient.SqlCommand("SELECT DISTINCT Class FROM tblStudents", conn) conn.Open() Dim dr As System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader rblClass.DataSource = dr rblClass.DataTextField = "Class" rblClass.DataBind() dr.Close() conn.Close() End If '在此处放置初始化页的用户代码 End Sub Private Sub dltScores_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dltScores.ItemCommand Select Case e.CommandName Case "select" dltScores.SelectedIndex = e.Item.ItemIndex BindList() Case "undelect" dltScores.SelectedIndex = -1 BindList() End Select End Sub Private Sub rblClass_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rblClass.SelectedIndexChanged Dim conn As New System.Data.SqlClient.SqlConnection("server=LIUQI;integrated security=SSPI;initial catalog=StudentMS") Dim cmd As New System.Data.SqlClient.SqlCommand cmd.Connection = conn cmd.CommandText = "SELECT*FROM tblStudents WHERE Class=" & rblClass.DataTextField & "" conn.Open() Dim dr As System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader ckbStudents.DataSource = dr ckbStudents.DataTextField = "Name" ckbStudents.DataValueField = "StudentID" ckbStudents.DataBind() dr.Close() conn.Close() End Sub Private Sub ckbStudents_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ckbStudents.SelectedIndexChanged BindList() End SubEnd Class
1 下一页