como actualizar registros de un datagrid con BD
Publicado por johan (1 intervención) el 22/05/2010 06:26:14
Buenas Noches lo que pasa es que necesito que me colaboren con lo siguiente si me hacen el favor...
TENGO INFORMACION EN UN DATAGRID Y TNGO UN BOTON ACTUALIZAR DATOS...PERO NECESITO QUE LO Q MODIFIKE EN EL DATARID ME KEDE TAMBN EN LA BASE DE DATOS...MIREN LO Q HE HECHO
cmd.CommandText = "Select * from clientes where nombre='" & Me.cbnombre.Text & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = conn
drss.Close()
drss = cmd.ExecuteReader
If drss.HasRows Then
drss.Read()
cod = drss.Item("codcliente")
End If
drss.Close()
'para actualizar la informacion del cliente
cmd.CommandText = "Update clientes set telefono='" & txttelefono.Text & "' ,ciudad='" & txtciudad.Text & "' where codcliente='" & cod & "'"
cmd.ExecuteNonQuery()
'para actualizar el nombre del cliente
cmd.CommandText = "Update clientes set nombre='" & cbnombre.Text & "' where codcliente='" & txtcodcli.Text & "'"
cmd.ExecuteNonQuery()
MsgBox("El registro se actualizo correctamente")
TENGO INFORMACION EN UN DATAGRID Y TNGO UN BOTON ACTUALIZAR DATOS...PERO NECESITO QUE LO Q MODIFIKE EN EL DATARID ME KEDE TAMBN EN LA BASE DE DATOS...MIREN LO Q HE HECHO
cmd.CommandText = "Select * from clientes where nombre='" & Me.cbnombre.Text & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = conn
drss.Close()
drss = cmd.ExecuteReader
If drss.HasRows Then
drss.Read()
cod = drss.Item("codcliente")
End If
drss.Close()
'para actualizar la informacion del cliente
cmd.CommandText = "Update clientes set telefono='" & txttelefono.Text & "' ,ciudad='" & txtciudad.Text & "' where codcliente='" & cod & "'"
cmd.ExecuteNonQuery()
'para actualizar el nombre del cliente
cmd.CommandText = "Update clientes set nombre='" & cbnombre.Text & "' where codcliente='" & txtcodcli.Text & "'"
cmd.ExecuteNonQuery()
MsgBox("El registro se actualizo correctamente")
Valora esta pregunta


0