VB.Net DataSet找不到表

时间:2014-08-28 12:00:12

标签: mysql vb.net join dataset

我有一个问题。我应该在某些表之间进行连接

sql = "select * from prodotto as p,fornitore as f,categoria as c where   
p.codice_fornitore=p.codice and p.codice_categoria=c.codice and p.codice='" & cod.Text & "'"


但是当我可以使用数据适配器填充我的数据集时,我应该使用哪个名称来引用查询结果。这是一个带有默认名称的临时表?

2 个答案:

答案 0 :(得分:1)

DataSet中的各个表可以通过从零开始的索引引用,因此您可以使用DataSet.Tables(0)来访问结果集,因为它似乎是查询中唯一的结果集。 / p>

答案 1 :(得分:1)

例如,

Private Sub FilldgvMyGrid()
   Dim SourceDataSet As New DataSet
   Dim adapter As New NpgsqlDataAdapter("select * from prodotto as p,fornitore as 
       f,categoria as c where p.codice_fornitore=p.codice and p.codice_categoria=c.codice    
       and p.codice='" & cod.Text & "'", yourSqlConn)

    adapter.Fill(SourceDataSet)
     /*if you have a Datagridview called dgvMyGrid */
    dgvMyGrid.DataSource = SourceDataSet.Tables(0)

End Sub