JDPAIZ DESDE MANAGUA, NICARAGUA PARA EL MUNDO
Gracias jose luis por tu pronta respuesta me a ayudado de mucho y leindo en otros foros solo recopile la informacion y logre acerlo aquiles les dejo el codigo para que se ayuden.
TODO ES CODIGO VBNET
Código PHP:
Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
Try
Using loConexion As New SqlConnection(conexion)
Dim lsQuery As String = String.Empty
loConexion.Open() ' abrir conexión
For Each loFila As DataGridViewRow In Me.DataGridView1.Rows
If lF_bExisteCodigo(loFila.Cells("codprod").Value.ToString()) = True Then
'Modificar registro
lsQuery = "UPDATE producto SET pc=@pc, pv=@pv, entrada=@entrada, existencia=@existencia Where cod_producto=@cod_producto"
' crear comando'
Dim loComando As New SqlCommand(lsQuery, loConexion)
'añadir parametros al comando'
loComando.Parameters.Clear()
loComando.Parameters.Add(New SqlParameter("@pc", CStr(loFila.Cells("pc").Value)))
loComando.Parameters.Add(New SqlParameter("@pv", CStr(loFila.Cells("pV").Value)))
loComando.Parameters.Add(New SqlParameter("@entrada", CStr(loFila.Cells("entrada").Value)))
loComando.Parameters.Add(New SqlParameter("@existencia", CStr(loFila.Cells("exist").Value)))
loComando.Parameters.Add(New SqlParameter("@cod_producto", loFila.Cells("codprod").Value))
loComando.ExecuteNonQuery()
End If
Next
End Using
Catch Exp As Exception
MessageBox.Show(Exp.Message, "Button2_Click", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub
TODO ES CODIGO VBNET
Código PHP:
Private Function lF_bExisteCodigo(ByVal cod_producto As String) As Boolean
Dim lbRetorno As Boolean = False
Dim lsQuery As String
Try
Using loConexion As New SqlConnection(conexion)
lsQuery = "Select Count(*) From producto Where cod_producto=@cod_producto"
Using loComando As New SqlCommand(lsQuery, loConexion)
añadir parametros al comando
loComando.Parameters.Add(New SqlParameter("@cod_producto", cod_producto))
loConexion.Open()
Dim liResultado As Integer = CInt(loComando.ExecuteScalar())
If liResultado > 0 Then
lbRetorno = True
End If
End Using
End Using
Catch Exp As SqlException
MessageBox.Show(Exp.Message, "lF_bExisteCodigo", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch Exp As Exception
MessageBox.Show(Exp.Message, "lF_bExisteCodigo", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
Return lbRetorno
End Function