Jump to content

Visual Basic .NET Base de Dados - Ajuda


Recommended Posts

Boas amigos, gostava da vossa ajuda para o código visto que não só muito experiente.

Eu quero realizararrow-10x10.pngarrow-10x10.pngarrow-10x10.png uma pesquisa com um textbox, quando escrevo o que pretendo procurararrow-10x10.pngarrow-10x10.pngarrow-10x10.png clico no enter e ele mostra os registos nos respectivos textboxes.

Aguardo resposta.

Edited by maxter
Link to comment
Share on other sites

Sub Pesquisa()

Using con As OleDbConnection = GetConnection()



Dim reader As OleDbDataReader

Dim sql As String = "SELECT * FROM Cadastro_Clientes WHERE Nome_Completo LIKE '%" & Form1.TextBox_nome.Text & "%' "

Dim cmd As OleDbCommand = New OleDbCommand(sql, con)

reader = cmd.ExecuteReader

While reader.Read

Form1.TextBox_endereco.Text = reader("Endereço")

Form1.TextBox_telefone.Text = reader("Telefone")

End While

Catch ex As Exception




End Try

End Using

End Sub

Private Sub TextBox_nome_TextChanged(sender As Object, e As EventArgs) Handles TextBox_nome.TextChanged

If TextBox_nome.Text <> "" Then



TextBox_endereco.Text = ""

TextBox_telefone.Text = ""

End If

End Sub

A primeira Sub foi escrita dentro de um Modulo ,a segunda dentro do evento da TextBox do Formulário, isso deve te ajudar, a pesquisa é feita pelo textbox_nome do formulário.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.