帮忙查找错误,谢谢
asp.net吧
全部回复
仅看楼主
level 1
帮忙查找一下下面的错误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
2006年08月10日 09点08分 1
level 1
点多选框后出错
2006年08月10日 09点08分 2
level 1
错误信息
2006年08月10日 09点08分 3
level 0
没看,估计sql语句错误。
2006年08月11日 07点08分 4
level 0
sql那里错了?
2006年08月12日 01点08分 5
level 0
strWhere &= "tblStudents.StudentID=" & itm.Value & ""->strWhere &= "" & "tblStudents.StudentID=" & itm.Value & ""这样变会不会没错了,你的""是指加个空格吧?
2006年08月29日 09点08分 6
level 0
ASP.NET交流群29464908
2006年08月31日 05点08分 7
level 0
将 dr = cmd.ExecuteReader改为dr= cmd.ExecteReader();可以的话在查查连接字符串看有没有语法错误.
2006年09月03日 07点09分 8
1