标题:“System.IndexOutOfRangeException”类型的未经处理的异常在 System.Data. ...
只看楼主
TStar
Rank: 1
来 自:上海
等 级:新手上路
帖 子:12
专家分:5
注 册:2013-9-29
结帖率:100%
 问题点数:0 回复次数:1 
“System.IndexOutOfRangeException”类型的未经处理的异常在 System.Data.dll 中发生
目的是实现模糊查询相关内容,但执行到“****”位置时出现标题所述异常,大家帮忙看看是怎么回事
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim cns As String = "Data Source=TSTAR;Initial Catalog=university;Integrated Security=True"
        Dim sql As String = "select student.snum,sname,cname,score from student join sc on student.snum=sc.snum join sections on sc.secnum=sections.secnum join course on where student.snum like '%" & TextBox1.Text & "%' or sname like'%" & TextBox2.Text & "%'"
        Dim con As New SqlConnection(cns)
        Dim sqlc As New SqlCommand(sql, con)
        con.Open()
        Dim rdr As SqlDataReader = sqlc.ExecuteReader()
        While rdr.Read()
            Dim li As New ListViewItem()
            li.SubItems.Clear()
            li.SubItems(0).Text = rdr("student.snum").ToString()****
            li.SubItems.Add(rdr("sname").ToString())
            li.SubItems.Add(rdr("cname").ToString())
            li.SubItems.Add(rdr("score").ToString())
            ListView1.Items.Add(li)
        End While
        rdr.Close()
        con.Close()
    End Sub
搜索更多相关主题的帖子: university course Object where 
2013-11-16 21:16
TStar
Rank: 1
来 自:上海
等 级:新手上路
帖 子:12
专家分:5
注 册:2013-9-29
得分:0 
哎……
把student.snum改成snum就可以了
2013-11-19 13:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-423633-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015390 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved