
recibir output de sql en vb.net
Publicado por anonymous (29 intervenciones) el 22/06/2020 15:09:38
buen día resulta que tengo un procedimiento que tiene una serie de parametros y por ultimo un output...
no se como ejecutar ese pr con un parametro output desde vb.net y q me devuelva el resultado en una caja de texto... les muestro como lo tengo hasta ahora
despues en el form donde llamo a ese parametro hago lo siguiente:
y en el evento click del boton llamo a ese public sub y le paso los valores
la verdad que no se como hacer...
agradezco mucho su ayuda. saludos!
no se como ejecutar ese pr con un parametro output desde vb.net y q me devuelva el resultado en una caja de texto... les muestro como lo tengo hasta ahora
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Public Function CalculaPrecio(CODPROD As String, CUENTACLIENTE As String, DTOGRAL As Decimal, DESCUENTO As Decimal, PRECIO As Decimal, LISTADEPRECIO As Integer) As OleDbDataReader
Dim myReader As OleDbDataReader
Try
Dim connexio As New OleDbConnection
Dim myCommand As New OleDbCommand
Dim campo As String
connexio = New OleDbConnection(myConnectionString)
myCommand.CommandText = ("CalculaPrecio")
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Connection = connexio
myCommand.Parameters.AddWithValue("@CODPROD", CODPROD)
myCommand.Parameters.AddWithValue("@CUENTACLIENTE", CUENTACLIENTE)
myCommand.Parameters.AddWithValue("@DTOGRAL", DTOGRAL)
myCommand.Parameters.AddWithValue("@DESCUENTO", DESCUENTO)
myCommand.Parameters.AddWithValue("@PRECIO", PRECIO)
myCommand.Parameters.AddWithValue("@LISTADEPRECIO", LISTADEPRECIO)
myCommand.Parameters("@PRECIOFINAL").Direction = ParameterDirection.Output
connexio.Open()
myReader = myCommand.ExecuteReader()
Dim PRECIOFINAL As Decimal = CInt(myCommand.Parameters("@PRECIOFINAL").Value)
Return myReader
Catch exc As Exception
MsgBox("Error: " & exc.Message)
Return myReader
End Try
End Function
despues en el form donde llamo a ese parametro hago lo siguiente:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Public Sub CalculaPrecio(CODPROD As String, CUENTACLIENTE As String, DTOGRAL As Decimal, DESCUENTO As Decimal, PRECIO As Decimal, LISTADEPRECIO As Integer)
Dim objStreamWriter As StreamWriter
Dim path As String
Windows.Forms.Application.DoEvents()
Dim myReader As OleDbDataReader
myReader = Data.CalculaPrecio(CODPROD, CUENTACLIENTE, DTOGRAL, DESCUENTO, PRECIO, LISTADEPRECIO)
Me.Refresh()
Windows.Forms.Application.DoEvents()
path = System.Windows.Forms.Application.StartupPath
End Sub
y en el evento click del boton llamo a ese public sub y le paso los valores
1
CalculaPrecio(txtCodProd.Text, txtClienteCuenta.Text, txtDescGral.Text, txtDescuento.Text, txtPrecio.Text, txtListaPrecio.Text)
la verdad que no se como hacer...
agradezco mucho su ayuda. saludos!
Valora esta pregunta


0