Jump to content

Recommended Posts

Posted

Boas pessoal,

Como posso selecionar uma linha completa e enviar para as textbox, estou a fazer assim, mas so me envia pelo nome, e ja defini as propriedade SelectModal para FullRowSelect


Dim contr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Acer\Desktop\Base de Dados.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

       ' Cria uma nova ligação à base de dados 
       Dim db As New SqlConnection(contr)

       Dim SQL As String = "SELECT * FROM Categoria where Nome ='" & DataGridView1(1, DataGridView1.CurrentRow.Index).Value & "'"
       ' DataGridView1.CurrentCell = DataGridView1.Item(0, DataGridView1.Rows.GetLastRow(DataGridViewElementStates.Visible))

       db.Open()

       Dim cmd As New SqlCommand(SQL, db)
       Dim dr As SqlClient.SqlDataReader
       dr = cmd.ExecuteReader
       Dim i As Integer = 0
       While dr.Read()
           TxtCategoria.Text = dr.Item("Codigo_Categoria")
           Txtnome.Text = dr.Item("Nome")
       End While
       dr.Close()
       db.Close()

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.