Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/08/2013, 14:36
lordbeliar2010
 
Fecha de Ingreso: junio-2013
Mensajes: 18
Antigüedad: 10 años, 10 meses
Puntos: 0
Respuesta: como actulizar bd desde un datagrivie no enlazado a una bd?

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.ObjectByVal e As System.EventArgsHandles 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(lsQueryloConexion
                        
'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.OKMessageBoxIcon.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(lsQueryloConexion
                    
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.OKMessageBoxIcon.Information
        Catch 
Exp As Exception 
            MessageBox
.Show(Exp.Message"lF_bExisteCodigo"MessageBoxButtons.OKMessageBoxIcon.Information
        
End Try 
        Return 
lbRetorno 
    End 
Function