Jump to content

Recommended Posts

Posted

Boa Noite, estou agora a aprender a mexer em bases de dados através do VB e tenho uma duvida. É possível pegar num campo da base de dados e colocá-lo num objecto do tipo(labels / listboxes / textboxes / etc..)? É que até agora só consigo visualizar resultados em datagridviewers.

Desde já obrigado pela atenção. 😕

Posted

boas

se consegues ver os campos no dgv

é so fazeres assim

Private Sub DataGridView1_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
txtbox.Text = DataGridView1.Rows(e.RowIndex).Cells(1).Value.ToString()

Cells(1) é o numero da coluna

cumps

acao

Posted

esta me a dar um erro:

 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim ConnectionString As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\baseteste.mdb")
        Dim query As String = "SELECT * FROM Login WHERE User = @User"

        Dim command As New OleDbCommand(query, ConnectionString)
        command.Parameters.Add("@User", OleDbType.VarChar).Value = TextBox1.Text

        Dim DataAdapter As New OleDbDataAdapter(command)
        Dim MyData As New DataSet
        DataAdapter.Fill(MyData, "Login")

        Me.DataGridView1.DataSource = MyData.Tables("Login")

        TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells(1).Value.ToString()
        TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells(2).Value.ToString()
    End Sub
esse é o codigo que tenho, e nesta parte:
        TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells(1).Value.ToString()
        TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells(2).Value.ToString()
as palavras e.rowindex dao erro.

o meu objectivo é quando o utilizador carregar num botão ele fazer uma pesquisa na base de dados pelo username e devolver a password.

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.