Binding Combobox to SQLServer 
Author Message
 Binding Combobox to SQLServer

Yes, you can do this at runtime.  All you need to do is the following:

            Me.ComboBox1.DataSource = Me.objpubs.authors
            Me.ComboBox1.DisplayMember = "phone"

Set your datasource to your object that holds a reference to the table you want to get data from then set the displaymember
to the column that you want displayed in the combobox.

For binding a textbox to a different table you will need to create a second datasource and repeat the steps above.



>Subject: Binding Combobox to SQLServer
>Date: Mon, 7 Jul 2003 17:58:02 -0400
>Lines: 17
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165

>Newsgroups: microsoft.public.dotnet.languages.vb.controls
>Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
>Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.languages.vb.controls:1191
>X-Tomcat-NG: microsoft.public.dotnet.languages.vb.controls

>Can a combo box be bound in code at runtime? If so, does anyone have any
>code showing how.  I would appreciate a working example on the pubs data in

>I can do all this in vb6 but .net is a different matter.  I used the upgrade
>wizard but it does only half the work ignoring such values as DataSource and

>I need the text bound to one table and the dropdown list bound to another


>Help Appreciated


This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the
terms specified at http://www.*-*-*.com/

Note:  For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread
from which they originated.  

Sun, 25 Dec 2005 05:07:41 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Synchronizing bound combobox and bound textboxes?

2. SQLServer Type for Bound Checkbox??

3. Referencing a combobox value and the concept of the bound column

4. Partialy bound ComboBox?

5. Multi-Column Data-Bound ComboBox

6. Multi column Bind ComboBox ??

7. Listbox/Combobox binding problem

8. ComboBox from DataSource bound to a DataGrid

9. ComboBox Binding Driving Me Crazy

10. Combobox Binding

11. Combobox Data Binding Hell

12. Bound ComboBox not hanlding Nulls


Powered by phpBB® Forum Software