You are on page 1of 2

Imports System.Data.

SqlClient
Public Class Form1
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


Dim sCnn As String = "Data Source = .; Initial Catalog =
dbPremiereProducts; Integrated Security = True"
Dim oConexion As New SqlConnection(sCnn)
Dim sSQL As String = ""
Dim oComando As New SqlCommand(sSQL, oConexion)
Dim oDataReader As SqlDataReader

sSQL = "SELECT DISTINCT ciudadcliente from tblCliente;"


oComando.CommandText = sSQL
oConexion.Open()
oDataReader = oComando.ExecuteReader
While oDataReader.Read
CMBCIUDAD.Items.Add(oDataReader(0))
End While
oConexion.Close()
End Sub

Private Sub BTNMOSTRAR_Click(sender As Object, e As EventArgs) Handles


BTNMOSTRAR.Click
Dim sCnn As String = "Data Source = .; Initial Catalog =
dbPremiereProducts; Integrated Security = True"
Dim oConexion As New SqlConnection(sCnn)
Dim sSQL As String = ""
Dim oComando As New SqlCommand(sSQL, oConexion)
Dim oDataReader As SqlDataReader

sSQL = "Select * FROM tblCliente ;"

Select Case CMBCIUDAD.SelectedItem


Case "Grove"
sSQL = "Select * FROM tblCliente WHERE ciudadCliente='Grove';"
Case "Crystal"
sSQL = "Select * FROM tblCliente WHERE ciudadCliente='Crystal';"
Case "Northfield"
sSQL = "Select * FROM tblCliente WHERE
ciudadCliente='Northfield';"
Case "Fillmore"
sSQL = "Select * FROM tblCliente WHERE ciudadCliente='Fillmore';"
Case "Altonville"
sSQL = "Select * FROM tblCliente WHERE
ciudadCliente='Altonville';"
Case "Sheldon"
sSQL = "Select * FROM tblCliente WHERE ciudadCliente='Sheldon';"
End Select

oComando.CommandText = sSQL
oConexion.Open()
oDataReader = oComando.ExecuteReader
DGVCLIENTE.Rows.Clear()
While oDataReader.Read
DGVCLIENTE.Rows.Add(oDataReader(0), oDataReader(1), oDataReader(4),
oDataReader(5))
End While
oConexion.Close()
End Sub
End Class

You might also like