标题:[求助]有关存储过程与ListView的问题
取消只看楼主
ninggang
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:637
专家分:0
注 册:2006-11-1
结帖率:40%
 问题点数:0 回复次数:0 
[求助]有关存储过程与ListView的问题
这是我的存储过程:
Create proc select_BS_Student
@Sno Varchar(15)
As
Begin
Select BS.ID,Book.Name,BS.BeginDate,BS.RemainDays
From Students,Book,BS
Where Students.SID=BS.SID and BS.ID=Book.ID and Students.Sno=@Sno
End
在应用程序中使用存储过程,呵呵:
Private Sub FillDataToListView2() ‘该过程的作用是将数据填充到LIstView2 中,呵呵
Try
If mycon.State = ConnectionState.Closed Then
mycon.Open()
End If
Dim sqlstr As String = "Exec select_BS_Student '" & TextBox1.Text & "'"
Dim myda As New SqlDataAdapter(sqlstr, mycon)
Dim myset As New DataSet
myda.Fill(myset, "information")
Dim i As Integer
Dim item As ListViewItem
Dim Subitem2 As ListViewItem.ListViewSubItem
Dim Subitem3 As ListViewItem.ListViewSubItem
Dim Subitem4 As ListViewItem.ListViewSubItem
For i = 0 To myset.Tables("information").Rows.Count - 1
With myset.Tables("information").Rows(i)
item = New ListViewItem
Subitem2 = New ListViewItem.ListViewSubItem
Subitem3 = New ListViewItem.ListViewSubItem
Subitem4 = New ListViewItem.ListViewSubItem
item = .Item("BS.ID") & ""
Subitem2 = .Item("Book.Name") & ""
Subitem3 = .Item("BS.BeginDate") & ""
Subitem4 = .Item("BS.RemainDays") & ""
item.SubItems.Add(Subitem2)
item.SubItems.Add(Subitem3)
item.SubItems.Add(Subitem4)
ListView2.Items.Add(item)
End With
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
然而当程序执行,调用该过程的时候,却说列"BS.ID"不属于information这是怎么搞的啊,奇怪,在新建存储过程的时候,我是写的这个列名啊,后来我有将起换成0,后面的依次加1,可又说格式转换错误,还是不懂,如果是单个表是没有问题
(直接将其写为item=.item("列名") & ""就行了)
搜索更多相关主题的帖子: Book Students ListView Sno 
2006-12-26 20:27



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




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

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