Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

mekanis

Combo Box + SQL

Recommended Posts

mekanis

Pessoal tenho este código:

 Private Sub carregar_clientes()
        Dim cliente As String = cmbcliente.Text

        Dim objDataAdapter_cliente As New SqlDataAdapter( _
        "SELECT id_cliente, nome, apelido " & _
        "FROM cliente ", objConnection)

        Dim objDataSet_cliente = New DataSet()
        objDataAdapter_cliente.Fill(objDataSet_cliente, "cliente")

        cmbcliente.DataSource = objDataSet_cliente.Tables(0)
        cmbcliente.DisplayMember = "nome"
        cmbcliente.ValueMember = "id_cliente"

        cmbcliente.Text = Nothing
        cmbcliente.SelectedText = cliente

        objDataAdapter_cliente = Nothing
        objDataSet_cliente = Nothing
    End Sub

E aparece o nome na combobox tudo bem.

Mas queria que aparecesse tambem o apelido e não dá simplesmente para fazer uma coisa destas

cmbcliente.DisplayMember = "nome" & " " & "apelido"

Podiam-me ajudar??

Cumpz

Share this post


Link to post
Share on other sites
ribeiro55

Porque não trazes os dados logo como queres?

SELECT id_cliente, nome + ' ' + apelido FROM cliente


Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Share this post


Link to post
Share on other sites
ribeiro55

SELECT  id_cliente, nome + ' ' + apelido AS [NomeApelido] FROM  cliente

Metes NomeApelido


Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Share this post


Link to post
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

×

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.