Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi friends.
I need get all of table names to
combobox.But i have no idea. i am using
vb.net
.please givi me ful code
Posted
Comments
graciax8 3-Feb-12 1:16am    
what database? please complete your question so we can help you faster. :)
Rajesh Anuhya 3-Feb-12 1:18am    
Repost
Amal anjula 3-Feb-12 1:26am    
im using sql server.

Your question is little confusing,I think you want to fetch database table name.so
If you are using SQL Server
use this query

C#
string str=SELECT name FROM sys.Tables;
  SqlCommand cmd = new SqlCommand(str, Db.GetConnection());
            
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                comboBox1.Items.Add(dr[0].ToString());
            }
 
Share this answer
 
Why you are Repost- My Answer[^] the Question , stick on One.

** don't spam the Board.

Thanks
--RA
 
Share this answer
 
Try this.

ddlteams is your combobox

VB
Dim dt As DataTable
       Dim ds As New DataSet()
       Dim con As New OdbcConnection(ConnStr)
       Dim da As New OdbcDataAdapter("SELECT DISTINCT team FROM phonebook ORDER BY team", con)
       con.Open()
       da.Fill(ds)
       dt = ds.Tables(0)

       'To list all tables use "select * from sys.objects where type=’u’"
       '*** DropDownlist ***' 
       With ddlTeams
           .DataSource = ds
           .DataTextField = "Team"
           .DataValueField = "Team"
           .DataBind()
       End With

       con.Close()


Regards,
@iamsupergrasya
 
Share this answer
 
v3

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