单击按钮时DataGridView中未显示数据

时间:2017-05-01 19:45:55

标签: vb.net visual-studio datagridview oracle-sqldeveloper

我正在使用VB制作一个小型Windows窗体应用程序,我正在尝试查看来自SUPPLIERS表的记录。当我按下“查看供应商”按钮时,它不起作用。我有另一个名为PARTS的表,我可以通过按下View Parts按钮查看这些部件。这很奇怪,因为它适用于不同表单上的PARTS表,但不适用于当前表单上的SUPPLIERS表。这是我的按钮代码。有什么我忘记的吗?

//显示当前表记录的代码

Private Sub viewSupplier_Click(sender As Object, e As EventArgs) Handles 
   viewSupplier.Click
   Dim ds As New DataSet
   ds = Form1.populateDS1()
   DataGridView1.DataSource = ds.Tables("DT_SUPPLIERS")
End Sub

//其他表的代码可以正常工作

Private Sub viewButton_Click(sender As Object, e As EventArgs) Handles 
       viewButton.Click
       Dim ds As New DataSet
       ds = Form1.populateDS()
       DataGridView1.DataSource = ds.Tables("DT_PART")
 End Sub

// DS AND DS1 Code
Public Function populateDS() As DataSet
        ds = New DataSet
        Dim sql As String
        Dim da As OracleDataAdapter
        sql = "SELECT * from PART"
        da = New OracleDataAdapter(sql, Connect())
        da.Fill(ds, "DT_PART")
        con.Close()
        Return ds
    End Function

    Public Function populateDS1() As DataSet
        ds = New DataSet
        Dim sql As String
        Dim da As OracleDataAdapter
        sql = "SELECT * from SUPPLIER"
        da = New OracleDataAdapter(sql, Connect())
        da.Fill(ds, "DT_SUPPLIER")
        con.Close()
        Return ds
    End Function

1 个答案:

答案 0 :(得分:0)

你的表名错了......改变这个......

 DataGridView1.DataSource = ds.Tables("DT_SUPPLIERS")

对此... (放弃" s")

 DataGridView1.DataSource = ds.Tables("DT_SUPPLIER")