3 tablas en un mismo DataGrid
Publicado por cabusia (3 intervenciones) el 31/05/2007 11:53:35
Hola ...
Quiero meter en un mismo grid los datos de 3 tablas ( ventas, compras,
inventario).Se me ocurren 3 formas de hacerlo pero no se como hacerlo.
.- 1 Forma. Tableadapter:
Las tablas estan agrupadas y no puedo crear un tableadaptert.
2. forma
Si creo 3 sqldatasource como puedo selecionar datos de cada uno de ellos ?
quiero coger del 1 sqldatasource el campo ventas, del 2 el campo compras y
del 3 el campo inventario. y todo ello plamarlo en el gridview .
3. forma
Con el dataadapter.
' Dataset Ventas
Dim CmdVen As OracleCommand = New OracleCommand("SELECT
TVAL1.DELCOD,DELNOM,COUNT(*) AS NUMALB, SUM((SELECT SUM(ALBARTCAN *
ALBLINPRC) FROM TVAL11 WHERE EMPRCOD='01' AND DELCOD=TVAL1.DELCOD AND
ALBCOD=TVAL1.ALBCOD)) as TOTVEN,SUM((SELECT SUM(ALBARTCAN * ALBPRECOS) FROM
TVAL11 WHERE EMPRCOD='01' AND DELCOD=TVAL1.DELCOD AND ALBCOD=TVAL1.ALBCOD))
as TOTCOM " & _
"FROM TVAL1,BDL01 WHERE TVAL1.EMPRCOD = '01' AND (ALBFEC >=:FecDes) AND
(ALBFEC <=:FecHas) AND TVAL1.DELCOD=BDL01.DELCOD AND
TVAL1.EMPRCOD=BDL01.EMPRCOD GROUP BY TVAL1.DELCOD,DELNOM", ConOra)
Dim DataVen As New OracleDataAdapter
DataVen.SelectCommand = CmdVen
' Generar Parametro de FechaDesde
CmdVen.Parameters.Add(New OracleParameter(":FecDes", OracleType.DateTime,
12))
' Asignar el valor al parametro
CmdVen.Parameters(":FecDes").Value = Date.Parse(Me.WebDateDes.Value)
' Generar Parametro de FechaHasta
CmdVen.Parameters.Add(New OracleParameter(":FecHas", OracleType.DateTime,
12))
' Asignar el valor al parametro
CmdVen.Parameters(":FecHas").Value = Date.Parse(Me.WebDateHas.Value)
DataVen.Fill(DsErka, "VENDEL")
Esto funciona correctamente, pero cuando asocio los valores a la variable
fila no coge los valores:
Dim fila As DsErka.VENDELRow
For Each fila In DsErka.VENDEL.Rows
For VarCon = 1 To 6
Me.GridVenDel.Rows(VarCon).Cells(1).Value = fila.DELNOM
Me.GridVenDel.Rows(VarCon).Cells(2).Value = fila.NUMALB
Me.GridVenDel.Rows(VarCon).Cells(3).Value = fila.TOTVEN
Me.GridVenDel.Rows(VarCon).Cells(4).Value = fila.TOTCOM
Me.GridVenDel.Rows(VarCon).Cells(5).Value = fila.MARGEN
Next
Next
Muchas gracias
Quiero meter en un mismo grid los datos de 3 tablas ( ventas, compras,
inventario).Se me ocurren 3 formas de hacerlo pero no se como hacerlo.
.- 1 Forma. Tableadapter:
Las tablas estan agrupadas y no puedo crear un tableadaptert.
2. forma
Si creo 3 sqldatasource como puedo selecionar datos de cada uno de ellos ?
quiero coger del 1 sqldatasource el campo ventas, del 2 el campo compras y
del 3 el campo inventario. y todo ello plamarlo en el gridview .
3. forma
Con el dataadapter.
' Dataset Ventas
Dim CmdVen As OracleCommand = New OracleCommand("SELECT
TVAL1.DELCOD,DELNOM,COUNT(*) AS NUMALB, SUM((SELECT SUM(ALBARTCAN *
ALBLINPRC) FROM TVAL11 WHERE EMPRCOD='01' AND DELCOD=TVAL1.DELCOD AND
ALBCOD=TVAL1.ALBCOD)) as TOTVEN,SUM((SELECT SUM(ALBARTCAN * ALBPRECOS) FROM
TVAL11 WHERE EMPRCOD='01' AND DELCOD=TVAL1.DELCOD AND ALBCOD=TVAL1.ALBCOD))
as TOTCOM " & _
"FROM TVAL1,BDL01 WHERE TVAL1.EMPRCOD = '01' AND (ALBFEC >=:FecDes) AND
(ALBFEC <=:FecHas) AND TVAL1.DELCOD=BDL01.DELCOD AND
TVAL1.EMPRCOD=BDL01.EMPRCOD GROUP BY TVAL1.DELCOD,DELNOM", ConOra)
Dim DataVen As New OracleDataAdapter
DataVen.SelectCommand = CmdVen
' Generar Parametro de FechaDesde
CmdVen.Parameters.Add(New OracleParameter(":FecDes", OracleType.DateTime,
12))
' Asignar el valor al parametro
CmdVen.Parameters(":FecDes").Value = Date.Parse(Me.WebDateDes.Value)
' Generar Parametro de FechaHasta
CmdVen.Parameters.Add(New OracleParameter(":FecHas", OracleType.DateTime,
12))
' Asignar el valor al parametro
CmdVen.Parameters(":FecHas").Value = Date.Parse(Me.WebDateHas.Value)
DataVen.Fill(DsErka, "VENDEL")
Esto funciona correctamente, pero cuando asocio los valores a la variable
fila no coge los valores:
Dim fila As DsErka.VENDELRow
For Each fila In DsErka.VENDEL.Rows
For VarCon = 1 To 6
Me.GridVenDel.Rows(VarCon).Cells(1).Value = fila.DELNOM
Me.GridVenDel.Rows(VarCon).Cells(2).Value = fila.NUMALB
Me.GridVenDel.Rows(VarCon).Cells(3).Value = fila.TOTVEN
Me.GridVenDel.Rows(VarCon).Cells(4).Value = fila.TOTCOM
Me.GridVenDel.Rows(VarCon).Cells(5).Value = fila.MARGEN
Next
Next
Muchas gracias
Valora esta pregunta


0