Select in the access database

Asked

Viewed 41 times

0

I’m having a hard time getting data from the bank. I can put it in my bank with that 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 search in the table users the "code" = 1 and select the "user" and "password" of this code and make it appear in the textbox3 and textbox4

Someone could help me?

1 answer

1


Taking into account that you will be searching 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 search the user password. I hope I’ve helped.

  • I understood your code, it helped a lot. Thank you for your help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.