You are on page 1of 3

Public Class Form1

Private Function leerBD(ByVal filtro As String) As String()


'conectarBD()
consultarBD("select coddis from distrito where nomdis='" & ComboBox3.Sel
ectedItem & "'")
If lector.Read() Then
datos(0) = lector("nomdis").ToString
datos(1) = lector("extendis").ToString
datos(2) = lector("foto").ToString
End If
lector.Close()
lector = Nothing
Return datos
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Ha
ndles Button1.Click
'conectarBD()
consultarBD("select * from distrito where nomdis='" & ComboBox3.Selected
Item & "'")
If lector.Read() Then
datos(0) = lector("nomdis").ToString
datos(1) = lector("extendis").ToString
datos(2) = lector("foto").ToString
End If
Label1.Text = datos(0).ToString
Label2.Text = datos(1).ToString
PictureBox1.Image = Image.FromFile("D:\anyelll\distrito\" & datos(2).ToS
tring)
lector.Close()
lector = Nothing
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handl
es MyBase.Load
conectarBD()
llenaCombo()
End Sub
Public Sub llenaCombo()
Me.ComboBox1.Items.Clear()
consultarBD("select nomdep from departamento")
If lector.Read() Then
'Label1.Text = lector.GetValue(0)
While lector.Read()
ComboBox1.Items.Add(lector.GetValue(0))
'datos(0) = lector("nomdep").ToString
End While
End If
lector.Close()
lector = Nothing
End Sub
Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As System.Eve

ntArgs) Handles ComboBox1.SelectedValueChanged


Me.ComboBox2.Items.Clear()
consultarBD("select coddep from departamento where nomdep='" & ComboBox1
.SelectedItem.ToString & "'")
If lector.Read() Then
datos(0) = lector("coddep").ToString
End If
lector.Close()
lector = Nothing
consultarBD("select nomprov from provincia where coddep = " & datos(0).T
oString)
If lector.Read() Then
While lector.Read()
Me.ComboBox2.Items.Add(lector.GetValue(0))
End While
End If
lector.Close()
lector = Nothing
End Sub
Private Sub ComboBox2_SelectedValueChanged(sender As Object, e As System.Eve
ntArgs) Handles ComboBox2.SelectedValueChanged
Me.ComboBox3.Items.Clear()
consultarBD("select codprov from provincia where nomprov='" & ComboBox2.
SelectedItem.ToString & "'")
If lector.Read() Then
datos(0) = lector("codprov").ToString
End If
lector.Close()
lector = Nothing
consultarBD("select nomdis from distrito where codprov = " & datos(0).To
String)
If lector.Read() Then
While lector.Read()
Me.ComboBox3.Items.Add(lector.GetValue(0))
End While
End If
lector.Close()
lector = Nothing
End Sub
Private Sub ComboBox3_SelectedIndexChanged(sender As System.Object, e As Sys
tem.EventArgs) Handles ComboBox3.SelectedIndexChanged
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, By
Val e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As Syst
em.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As Syst
em.EventArgs) Handles PictureBox2.Click

End Sub
End Class

You might also like