Solved

VB.NET MSSQL Read column namn by query?

Posted on 2011-09-14
7
405 Views
Last Modified: 2012-05-12
Hi.

I would like to get the column name from a database.

Can I do this in a query or something?

If I know the database is Named  "DBTEST"

Can I then do a query like..

Select from DBTEST "Column namn"


What i would like to do is to in my VB.NET application connect to the database,
Check wich column that exits in the database and then write values to these columns whit a new query...

I hop someone understand what I mean.

/Kavvis
0
Comment
Question by:kavvis
  • 4
  • 2
7 Comments
 
LVL 18

Expert Comment

by:deighton
ID: 36536016
if you use a DataAdapter to populate a DataTable, with the SQL being SELECT * FROM DBTEST WHERE 1=0

then you will have a collection of column objects in the datatable that you can cycle through
0
 

Author Comment

by:kavvis
ID: 36536046
ok! Hmmm... I'm pretty new at this can you give some example that I can work whit... I would like to fill a Listbox whit this info.. So I have all The columns that exits in The database in a Listbox....
0
 
LVL 21

Accepted Solution

by:
Alpesh Patel earned 500 total points
ID: 36536234
select * from sys.columns
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

Author Comment

by:kavvis
ID: 36536245
PatelAlpesh:
I'm Not sure what you mean right now...

0
 

Author Comment

by:kavvis
ID: 36536316
I have found some info like this...

select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'DBTEST'

Is this the right way to go?
0
 

Author Closing Comment

by:kavvis
ID: 36536371
thank I think I understand right now!
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 36541093
You can use both Infomation_schema and sys.columns
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now