Visual basic - mantenimiento

Solo disponible en BuenasTareas
  • Páginas : 4 (947 palabras )
  • Descarga(s) : 0
  • Publicado : 25 de noviembre de 2010
Leer documento completo
Vista previa del texto
System.Data
Imports System.Data.SqlClient

Public Class Form1
Private Cnx As New SqlConnection("User id=sa;password=rhys;server=Paul-VAIO;database=autos")
Private Dap As NewSqlDataAdapter("Select * from Autos", Cnx)
Private Dst As New DataSet
Private Cmd As New SqlCommand
Private p As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Dap.Fill(Dst, "Autos")
dgvAutos.DataSource = Dst.Tables("Autos")

Dap.SelectCommand.CommandText = "Select*from Marcas"Dap.Fill(Dst, "Marcas")
With cmbMarca
.DataSource = Dst.Tables("Marcas")
.DisplayMember = "NomMarca"
.ValueMember = "IdMarca"
End WithDap.SelectCommand.CommandText = "Select*from Colores"
Dap.Fill(Dst, "Colores")
With cmbColor
.DataSource = Dst.Tables("Colores")
.DisplayMember = "NomColor".ValueMember = "IdColor"
End With

Dap.SelectCommand.CommandText = "Select*from Modelos"
Dap.Fill(Dst, "Modelos")
With cmbModelo
.DataSource =Dst.Tables("Modelos")
.DisplayMember = "NomModelo"
.ValueMember = "IdModelo"
End With
Call mostrardatos()
End Sub
Private Sub mostrardatos()p = dgvAutos.CurrentCell.RowIndex
txtPlaca.Text = dgvAutos.Item(0, p).Value
txtApellidos.Text = dgvAutos.Item(1, p).Value
txtNombres.Text = dgvAutos.Item(2, p).ValuetxtFecha.Text = dgvAutos.Item(3, p).Value
cmbMarca.SelectedValue = dgvAutos.Item(4, p).Value
cmbModelo.SelectedValue = dgvAutos.Item(5, p).Value
cmbColor.SelectedValue =dgvAutos.Item(6, p).Value
End Sub
Private Sub dgvAutos_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvAutos.Click
mostrardatos()
End Sub
Private...
tracking img