- Tema Autor
- #1
Que tal compañeros vacunos, espero que alguien me pueda ayudar con lo que tengo, se trata de lo siguiente en c# acceso a mi tabla MySQL la cual tiene 32 campos (lo se esta algo grande, estoy haciendo mi aplicacion por fuera), pero yo no quiero que salgan los 32 sino los 10 que necesito, y lo que quiero es que el data grid me muestre los datos despues del segundo select, le pongo el codigo:
cmd1.CommandText = String.Format("SELECT * FROM mitabla{2} WHERE fecha>=CTOD('{0}') AND fecha<=CTOD('{1}')", fechaIni.Value.ToString("MM/dd/yyyy"), fechaFin.Value.ToString("MM/dd/yyyy"), centro);
DataTable tbl1 = new DataTable();
OleDbDataReader rdr1 = cmd1.ExecuteReader();
tbl1.Load(rdr1);
var visualDato = from ren in tbl1.AsEnumerable() select ren;
dataOrigen.DataSource = visualDato;
totalEfectivo.Text = tbl1.Compute("SUM(efectivo)","efectivo>0").ToString();
totalTarjeta.Text = tbl1.Compute("SUM(tarjeta)", "tarjeta>0").ToString();
totalDeposito.Text = tbl1.Compute("SUM(deposito)", "deposito>0").ToString();
totalNotaCredito.Text = tbl1.Compute("SUM(ncredito)", "ncredito>0").ToString();
totalFacturado.Text = tbl1.Compute("SUM(efectivo)+SUM(tarjeta)+SUM(deposito)", "lfactura=true").ToString();
totalVenta.Text = tbl1.Compute("SUM(efectivo)+SUM(tarjeta)+SUM(deposito)+SUM(ncredito)", "1=1").ToString();
Cursor.Current = Cursors.Default;
TimeSpan ts = fechaFin.Value - fechaIni.Value;
MessageBox.Show(ts.Days.ToString());
Entonces segun yo selecciono mis fechas hago el query entre fechas que ya le habia dado, y obtengo mi resultado en el datagrid1, de este datagrid1 quiero sacar a datagrid2 datos que cumplan lo que les diga en un where tarjeta>0 and efectivo=0.
Si me pueden ayudar bienvenida sea la ayuda, y de ante mano muchas gracias.:eolo::mota:
cmd1.CommandText = String.Format("SELECT * FROM mitabla{2} WHERE fecha>=CTOD('{0}') AND fecha<=CTOD('{1}')", fechaIni.Value.ToString("MM/dd/yyyy"), fechaFin.Value.ToString("MM/dd/yyyy"), centro);
DataTable tbl1 = new DataTable();
OleDbDataReader rdr1 = cmd1.ExecuteReader();
tbl1.Load(rdr1);
var visualDato = from ren in tbl1.AsEnumerable() select ren;
dataOrigen.DataSource = visualDato;
totalEfectivo.Text = tbl1.Compute("SUM(efectivo)","efectivo>0").ToString();
totalTarjeta.Text = tbl1.Compute("SUM(tarjeta)", "tarjeta>0").ToString();
totalDeposito.Text = tbl1.Compute("SUM(deposito)", "deposito>0").ToString();
totalNotaCredito.Text = tbl1.Compute("SUM(ncredito)", "ncredito>0").ToString();
totalFacturado.Text = tbl1.Compute("SUM(efectivo)+SUM(tarjeta)+SUM(deposito)", "lfactura=true").ToString();
totalVenta.Text = tbl1.Compute("SUM(efectivo)+SUM(tarjeta)+SUM(deposito)+SUM(ncredito)", "1=1").ToString();
Cursor.Current = Cursors.Default;
TimeSpan ts = fechaFin.Value - fechaIni.Value;
MessageBox.Show(ts.Days.ToString());
Entonces segun yo selecciono mis fechas hago el query entre fechas que ya le habia dado, y obtengo mi resultado en el datagrid1, de este datagrid1 quiero sacar a datagrid2 datos que cumplan lo que les diga en un where tarjeta>0 and efectivo=0.
Si me pueden ayudar bienvenida sea la ayuda, y de ante mano muchas gracias.:eolo::mota: