Galera bom dia mais uma vez,
Estou desenvolvendo uma aplicação e gostaria de saber o seguinte:
Eu tenho um textbox chamada CEP e tenho dois campos no banco chamados CEP_D e CEP_E, que possuem CEP's serem pesquisados.
Há possibilidade de usar esta textbox para pesquisar tanto no campo CEP_D quanto no campo CEP_E ?
Este é o meu código
Agradeço a compreensão :D
Public Class frmPesquisa
Private Sub carregargrid()
strsql = "SELECT * FROM Lograd_MSE_Nov2014 ORDER BY Denominação"
Dim objCommand As New OleDbCommand(strsql, conn)
dr_Lograd_MSE_Nov2014 = objCommand.ExecuteReader()
bs_Lograd_MSE_Nov2014.DataSource = dr_Lograd_MSE_Nov2014
DataGridView1.DataSource = bs_Lograd_MSE_Nov2014
End Sub
Private Sub limpar()
TextBoxCEP.Clear()
TextBoxRua.Clear()
'TextBoxNumero.Clear()
TextBoxBairro.Clear()
TextBoxDistrito.Clear()
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn.Open()
carregargrid()
End Sub
Private Sub TextBoxRua_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxRua.TextChanged
strsql = "SELECT * FROM Lograd_MSE_Nov2014 where Denominação like '" + TextBoxRua.Text + "%' AND Distrito like'" + TextBoxDistrito.Text + "%' AND CEP_D like'" + TextBoxCEP.Text
+ "%' AND BAIRRO_D like '" + TextBoxBairro.Text + "%' ORDER BY Denominação"
Dim objCommnad As New OleDbCommand(strsql, conn)
dr_Lograd_MSE_Nov2014 = objCommnad.ExecuteReader
bs_Lograd_MSE_Nov2014.DataSource = dr_Lograd_MSE_Nov2014
End Sub
Private Sub TextBoxDistrito_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxDistrito.TextChanged
strsql = "SELECT * FROM Lograd_MSE_Nov2014 where Denominação like '" + TextBoxRua.Text + "%' AND Distrito like'" + TextBoxDistrito.Text + "%' AND CEP_D like'" + TextBoxCEP.Text
+ "%' AND BAIRRO_D like '" + TextBoxBairro.Text + "%' ORDER BY Denominação"
Dim objCommnad As New OleDbCommand(strsql, conn)
dr_Lograd_MSE_Nov2014 = objCommnad.ExecuteReader
bs_Lograd_MSE_Nov2014.DataSource = dr_Lograd_MSE_Nov2014
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
frmResultadoPesquisa.ShowDialog()
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub frmPesquisa_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If MsgBox("Deseja realmente sair?? ", MsgBoxStyle.YesNo, "Encerrando.......") = MsgBoxResult.No Then
e.Cancel = True
Else
conn.Close()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
limpar()
End Sub
Private Sub TextBoxCEP_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxCEP.TextChanged
strsql = "SELECT * FROM Lograd_MSE_Nov2014 where Denominação like '" + TextBoxRua.Text + "%' AND Distrito like'" + TextBoxDistrito.Text + "%' AND CEP_D like'" + TextBoxCEP.Text
+ "%' AND BAIRRO_D like '" + TextBoxBairro.Text + "%' ORDER BY Denominação"
Dim objCommnad As New OleDbCommand(strsql, conn)
dr_Lograd_MSE_Nov2014 = objCommnad.ExecuteReader
bs_Lograd_MSE_Nov2014.DataSource = dr_Lograd_MSE_Nov2014
End Sub
Private Sub TextBoxNumero_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBoxBairro_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxBairro.TextChanged
strsql = "SELECT * FROM Lograd_MSE_Nov2014 where Denominação like '" + TextBoxRua.Text + "%' AND Distrito like'" + TextBoxDistrito.Text + "%' AND CEP_D like'" + TextBoxCEP.Text
+ "%' AND BAIRRO_D like '" + TextBoxBairro.Text + "%' ORDER BY Denominação"
Dim objCommnad As New OleDbCommand(strsql, conn)
dr_Lograd_MSE_Nov2014 = objCommnad.ExecuteReader
bs_Lograd_MSE_Nov2014.DataSource = dr_Lograd_MSE_Nov2014
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
Private Sub DataGridView1_SortCompare(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewSortCompareEventArgs) Handles DataGridView1.SortCompare
End Sub
Private Sub Label2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
End Class