Jump to content
Sign in to follow this  

[Resolvido] Combobox com databinding

Recommended Posts



Quero preencher uma combobox através do databinding com os anos de uma determinada tabela da base de dados, para isso uso o código abaixo, no entanto não me está a devolver os anos

Dim connection As New SqlConnection(myConnectionString)
 Dim str1 As String = "select Distinct Year(Data) from Cliente order by Year(data) desc"
Dim da As New SqlDataAdapter(str1, connection)
 Dim dataSet1 As New DataSet()
 da.Fill(dataSet1, "Cliente")
 Dim DataViewManager1 As DataViewManager = dataSet1.DefaultViewManager
 ComboBox2.DataSource = DataViewManager1
 ComboBox2.DisplayMember = "Clientes.Data"

Na combobox aparece preenchida com isto "System.Data.DataViewManagerListItemTypeDescriptor"

Edited by Caça

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 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.