
Ayuda consulta mysql-vb.net con parametros o variables
Publicado por Alfredo (9 intervenciones) el 16/07/2021 00:05:30
Amigos,
tengo un problema al pasar esta consulta a vb.net.. desde la consola no hay problemas, pero al pasarla al vb.net presenta muchos errores fatales:
el código desde misma consola mysql es:
por favor... si alguien me puede apoyar con esto..
gracias
tengo un problema al pasar esta consulta a vb.net.. desde la consola no hay problemas, pero al pasarla al vb.net presenta muchos errores fatales:
el código desde misma consola mysql es:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
set @total:=0;
set @acum:=0;
select mov_comprobante,mov_descripcion,mov_debe, mov_haber,@acum:=(select sum(mov_debe - mov_haber) as Anterior from Movimiento_contable where org_rut="123456" and cen_codigo="12345" and mov_fecha between '2021-01-01' and '2021-05-31')
as SaldoAnterior ,@total:=mov_debe- mov_haber +@total + @acum as Saldo
from movimiento_contable where org_rut="123456" and cen_codigo="12345" and mov_fecha between '2021-06-01' and '2021-06-30'
y desde VB.net es:
Sql = "SELECT mov_descripcion, mov_fecha, mov_tipo, mov_comprobante, mov_documento, mov_numero, mov_glosa, mov_debe, mov_haber, " & _
"@acum=(select sum(mov_debe - mov_haber) as Anterior from Movimiento_contable where org_rut="123456" and cen_codigo="12345" and mov_fecha between '2021-01-01' and '2021-05-31')
as SaldoAnterior , " & _
"(@total1 = @total1 + mov_debe - mov_haber+@acum) as saldo" & _
"FROM movimiento_contable " & _
" where ORG_RUT= '" & "123456" & "' and cen_codigo= '" & "12345" & "' and mov_fecha between '2021-06-01' and '2021-06-30' order by mov_fecha asc"
Dim llenar As New DataTable
Dim cmd As New MySqlCommand(Sql, Conexion)
cmd.Parameters.AddWithValue("@total", 0)
cmd.Parameters.AddWithValue("@acum", 0)
Dim data As New MySqlDataAdapter(cmd)
data.Fill(llenar)
por favor... si alguien me puede apoyar con esto..
gracias
Valora esta pregunta


0