Hi

I want to add the table names from a database in sql server to a combobox with vb.net windows programming.

Its a customer accounts database where for instance I add a new Account holder which creates a new Table and when I want to view a specific account holder a want to select that account holder from a combobox that views the Table names.

Im completely lost about this and if anyone can help me would be great.

Thanks
Hannes

USE YourDBName
GO
SELECT *
FROM sys.Tables
GO

hope this helps

Imports System.data.sqlclient
Imports system.data

dim objcon as new sqlconnection
dim dt as new datatable

dim str as string = " DataBase Path "

If objcon.state = connectionstate.closed()
objcon.connectionstring = str
objcon.open()
end if

dim query as string="select * from infomation_schema.tables"
dim da as new sqldataadapter(query,objcon)
da.fill(dt)

dropdownlist1.datasource = dt
dropdownlist1..datatextfield = "table_name"
dropdownlist1..databind()

objcon.close()

also you can use code below to connect to your database

"data source=.\sqlexpress;attachdbfilename=|datadirectory|\database.mdf;_
integrated security=true;user instance=true;"

RED Desc : use your DataBase name

KOUROSH NIKZAD

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.