Aspectos networking
Enviado por hectorsd_ • 15 de Enero de 2021 • Ensayo • 544 Palabras (3 Páginas) • 104 Visitas
frmClientes
Boton Actualizar...
____________________
Dim cadena As String = "Data Source=DELL\;Initial Catalog=Facturacion;Integrated Security=True"
Dim conexion As New SqlClient.SqlConnection()
conexion = New SqlClient.SqlConnection(cadena)
conexion.Open()
'If conexion.State = ConnectionState.Open Then
Dim DA As New SqlClient.SqlDataAdapter("SELECT * FROM clientes", conexion)
Dim DT As New DataTable
DA.Fill(DT)
DataGridView1.DataSource = DT
'End If
conexion.Close()
______________________________
frmACliente
Boton Grabar..
_________________
Try
Dim hookUp As New SqlClient.SqlConnection("Data Source=DELL\;Initial Catalog=Facturacion;Integrated Security=True")
Dim str As String = "INSERT INTO clientes(nombre, apellido,credito,limite)VALUES(@Nombre, @Apellido,@Credito,@Limite)"
Dim cmd As New SqlClient.SqlCommand(str, hookUp)
hookUp.Open()
cmd.Parameters.Clear()
cmd.Parameters.Add("@Nombre", txtNombre.Text)
cmd.Parameters.Add("@Apellido", txtApellido.Text)
cmd.Parameters.Add("@Credito", txtCredito.Text)
cmd.Parameters.Add("@Limite", txtLimite.Text)
cmd.ExecuteNonQuery()
hookUp.Close()
MsgBox("Registro Grabado")
Me.Close()
Catch ex As Exception
MsgBox(ex.Message())
End Try
______________________
frmClientes
Boton Borrar...
______________________
Dim AuxID As String
Try
AuxID = DataGridView1.SelectedRows(0).Cells(0).Value.ToString()
Dim hookUp As New SqlClient.SqlConnection("Data Source=ROCAFER-HP;Initial Catalog=Facturacion;Integrated Security=True")
Dim str As String = "DELETE FROM clientes WHERE id=@IdCliente"
Dim sqlCmd As New SqlClient.SqlCommand(str, hookUp)
sqlCmd.Parameters.Add("@IdCliente", AuxID)
hookUp.Open()
sqlCmd.ExecuteNonQuery()
hookUp.Close()
MsgBox("Registro Borrado")
' Me.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
...