Actualizar existencia de un producto
Publicado por Tony (1 intervención) el 08/12/2021 00:30:13
Estoy trabajando con sql y vb.net tengo un combobox con dos datos "ENTRADA" y "SALIDA" y dos textbox que es para la cantidad que desea sumar o restar y otro para el ID del producto al seleccionar "ENTRADA" mi programa en visual debe sumar esa cantidad al ID producto que seleccione en una tabla que tengo en SQL tengo el siguiente codigo que deberia funcionarme pero me da este error : error incorrect syntax near the keyword "where"
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Try
opcion = ComboBox1.SelectedIndex
If opcion = 0 Then
Dim comando As SqlCommand
Dim strSQL As String
Dim conexion As New SqlConnection("server=Anthony-D\SQLEXPRESS; initial catalog=inventarios; integrated security=true")
conexion.Open()
strSQL = "update tblProductos set existencia = existencia +" & TextBox2.Text & " where idProducto =" & TextBox1.Text
comando = New SqlCommand(strSQL, conexion)
comando.ExecuteNonQuery()
MsgBox("Registro actualizado")
conexion.Close()
comando.Dispose()
transaccion = "Entrada"
End If
Catch ex As Exception
MsgBox("Error " & ex.Message)
End Try
end sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Try
opcion = ComboBox1.SelectedIndex
If opcion = 0 Then
Dim comando As SqlCommand
Dim strSQL As String
Dim conexion As New SqlConnection("server=Anthony-D\SQLEXPRESS; initial catalog=inventarios; integrated security=true")
conexion.Open()
strSQL = "update tblProductos set existencia = existencia +" & TextBox2.Text & " where idProducto =" & TextBox1.Text
comando = New SqlCommand(strSQL, conexion)
comando.ExecuteNonQuery()
MsgBox("Registro actualizado")
conexion.Close()
comando.Dispose()
transaccion = "Entrada"
End If
Catch ex As Exception
MsgBox("Error " & ex.Message)
End Try
end sub
Valora esta pregunta


0