[求助]有关存储过程与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("列名") & ""就行了)