visto che ci siamo, per completezza riportiamo il codice (MSDN) nel caso si voglia volontariamente riempire un Dataset con più tabelle:
codice:
//....(customerConnection e orderConnection sono due connessioni valide)
SqlDataAdapter custAdapter = new SqlDataAdapter("SELECT * FROM dbo.Customers", customerConnection);
OleDbDataAdapter ordAdapter = new OleDbDataAdapter("SELECT * FROM Orders", orderConnection);
DataSet customerOrders = new DataSet();
custAdapter.Fill(customerOrders, "Customers");
ordAdapter.Fill(customerOrders, "Orders");
Si avranno due Datatable nel Dataset:
customerOrders.Tables["Customers"] (oppure [0])
e
customerOrders.Tables["Orders"] (oppure [1])
Inoltre, per fare cio' che dice Gluck, dovresti modificare il tuo metodo così:
codice:
public DataTable getGiacenze(string articoli)
{
OdbcCommand cmd = new OdbcCommand();
OdbcDataAdapter adapter = new OdbcDataAdapter();
DataSet ds = new DataSet();
try
{
cmd.CommandText = ".........";
cmd.Connection = conn;
adapter.SelectCommand = cmd;
adapter.Fill(ds);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
ds.Dispose();
conn.Close();
}
return ds.Tables[0];
}
pero' se svisceriamo sempre in questo modo non lavorero' piu'...