Select access bank

0

I'm having trouble getting data from the bank. I can insert into my bank with this code

    Dim comandosql As OleDbCommand
    cadastro = "Insert INTO usuarios (usuario, senha) Values ('" & TextBox1.Text & "','" & TextBox2.Text & "')"
    comandosql = New OleDbCommand(cadastro, conexao)
    comandosql.ExecuteNonQuery()
    MsgBox("Dados inseridos com sucesso")

Now I wanted to select the data already registered, for example look in the table users "code" = 1 and select the "user" and "password" of this code and make it appear in textbox3 and textbox4

Could someone help me?

    
asked by anonymous 28.05.2018 / 20:52

1 answer

1

Considering that you will be searching for this data from a single user you can use the following code:

Dim comandosql as OleDbCommand
Dim reader As OleDbDataReader = Nothing
busca = "Select senha from usuarios where usuario = " & Textbox3.Text
comandosql = New OleDbCommand(busca, conexao)
reader = comandosql.Executereader()
TextBox4.Text = reader.Read()
read.Close()

So you look up the user's password. I hope I have helped.

    
06.06.2018 / 17:12