这是我的代码,它不会在我的列表中恢复选择查询的结果:
Imports Oracle.DataAccess.Client
Public Class ListForm
Private Sub ListForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cn As OracleConnection
cn = New OracleConnection("User ID=admin;password=admin;")
Dim cmd As New OracleCommand()
cmd.Connection = cn
cn.Open()
cmd.CommandText = "select name from system.Table"
Dim dr As OracleDataReader = cmd.ExecuteReader()
While dr.Read()
List.Items.Add(dr.GetValue(0))
End While
dr.Close()
End Sub
End Class
答案 0 :(得分:1)
在循环中放置一个断点,看看list.items.add方法的调用次数。如果为零,请检查数据库查询。如果执行,请检查dr.GetValue(0)的值。如果这是正常的,您可能需要刷新列表。