2014-08-28 55 views
0

我有疑難問題應該做一些表之間的連接VB.Net 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 & "'" 


但是當我可以填補我的數據集的數據適配器,它的名字我應該用於引用query.is的結果與默認名稱臨時表?

回答

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 
1

DataSet中的各個表可以由基於零的索引引用,因此您可以使用DataSet.Tables(0)訪問結果集,因爲它似乎是查詢中唯一的結果集。