Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

How to import data from database to combo box?I have the explanation:-

Database: Example.accdb
Table in DB: Table 1, Table 2 and Table 3
Combo Box: cboImport

Assume that i want to import data from table 2 to combo box. What is the command/coding?Could someone give me dummy coding for this problems?
Posted
Comments
Suman Zalodiya 15-Sep-11 1:45am    
Hi Fadhli,

Please let me know you are asking for windows application or web application?
Luiey Ichigo 15-Sep-11 2:12am    
windows application..

1 solution

Dim cn as new OledbConnection("Provider=Microsoft.Ace.12.0; Data Source=Example.accdb")
cn.open()
Dim da as OledbDataAdapter("select * from Table2",cn)
Dim tbl as new DataTable
da.fill(tbl)
With cboImport
.DataSource=tbl
.DisplayMember="ColumnName1"
.ValueMember="ColumnName2"
End With
cn.Close()
 
Share this answer
 
Comments
Luiey Ichigo 15-Sep-11 2:08am    
Tq Bun Leap. I'll try this code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900