Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


VB.NET MSSQL Read column namn by query?

Posted on 2011-09-14
Medium Priority
Last Modified: 2012-05-12

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.

Question by:kavvis
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 18

Expert Comment

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

Author Comment

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....
LVL 21

Accepted Solution

Alpesh Patel earned 2000 total points
ID: 36536234
select * from sys.columns
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.


Author Comment

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


Author Comment

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


Is this the right way to go?

Author Closing Comment

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

Expert Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

604 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