Mejor forma de acceder a datos
Publicado por Rocio (2 intervenciones) el 19/05/2008 19:04:28
Vengo migrando de VB6 a VB.net y se me plantea esta duda que espero que los maestros me asesoren...
La cuestion es que tengo (o sé) de 2 formas de acceder en este caso es un ejemplo para modificar el contenido de una base de datos.
Mi pregunta es cual de los metodos es el mejor metodo.
Metodo 1º
'Sql_Actualizar = "UPDATE Clientes SET" & _
'" Codigo=" & TxtCodigo.Text & "," & _
'" Cliente='" & TxtCliente.Text & "'," & _
'" Direccion='" & TxtDireccion.Text & "'," & _
'" CodigoPostal='" & TxtCodPostal.Text & "'," & _
'" Poblacion='" & TxtPoblacion.Text & "'," & _
'" Provincia='" & TxtProvincia.Text & "'," & _
'" Pais=" & ComboPais.Items(ComboPais.SelectedIndex).itemdata & "," & _
'" CIF='" & TxtCifNif.Text & "'," & _
'" Telefono='" & TxtTelefono.Text & "'," & _
'" Fax='" & TxtFax.Text & "'," & _
'" RecEquiv=" & ChkRecargoEqu.Checked & "," & _
'" FormaPago=" & ComboFPago.Items(ComboFPago.SelectedIndex).itemdata & _
'" WHERE codigo=" & Tabla.CurrentRow.Cells(0).Value
'SqlDatEmp.EjecutarSql(Sql_Actualizar)
'SqlDatEmp.ActualizarDatos("Clientes")
'ActualizarDatos()
'ControlCancelar_Click(sender, e)
Metodo 2º
SqlDatEmp.AbrirTabla("SELECT * FROM Clientes WHERE codigo=" & Tabla.CurrentRow.Cells(0).Value, "NuevoReg")
Dim DR As DataRow = SqlDatEmp.objDS.Tables("NuevoReg").Rows(0)
DR("Codigo") = TxtCodigo.Text
DR("Cliente") = TxtCliente.Text
'...
SqlDatEmp.ActualizarDatos("NuevoReg")
ActualizarDatos()
ControlCancelar_Click(sender, e)
Gracias
La cuestion es que tengo (o sé) de 2 formas de acceder en este caso es un ejemplo para modificar el contenido de una base de datos.
Mi pregunta es cual de los metodos es el mejor metodo.
Metodo 1º
'Sql_Actualizar = "UPDATE Clientes SET" & _
'" Codigo=" & TxtCodigo.Text & "," & _
'" Cliente='" & TxtCliente.Text & "'," & _
'" Direccion='" & TxtDireccion.Text & "'," & _
'" CodigoPostal='" & TxtCodPostal.Text & "'," & _
'" Poblacion='" & TxtPoblacion.Text & "'," & _
'" Provincia='" & TxtProvincia.Text & "'," & _
'" Pais=" & ComboPais.Items(ComboPais.SelectedIndex).itemdata & "," & _
'" CIF='" & TxtCifNif.Text & "'," & _
'" Telefono='" & TxtTelefono.Text & "'," & _
'" Fax='" & TxtFax.Text & "'," & _
'" RecEquiv=" & ChkRecargoEqu.Checked & "," & _
'" FormaPago=" & ComboFPago.Items(ComboFPago.SelectedIndex).itemdata & _
'" WHERE codigo=" & Tabla.CurrentRow.Cells(0).Value
'SqlDatEmp.EjecutarSql(Sql_Actualizar)
'SqlDatEmp.ActualizarDatos("Clientes")
'ActualizarDatos()
'ControlCancelar_Click(sender, e)
Metodo 2º
SqlDatEmp.AbrirTabla("SELECT * FROM Clientes WHERE codigo=" & Tabla.CurrentRow.Cells(0).Value, "NuevoReg")
Dim DR As DataRow = SqlDatEmp.objDS.Tables("NuevoReg").Rows(0)
DR("Codigo") = TxtCodigo.Text
DR("Cliente") = TxtCliente.Text
'...
SqlDatEmp.ActualizarDatos("NuevoReg")
ActualizarDatos()
ControlCancelar_Click(sender, e)
Gracias
Valora esta pregunta


0