Solved

VB.NET MSSQL Read column namn by query?

Posted on 2011-09-14
7
404 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

757 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

20 Experts available now in Live!

Get 1:1 Help Now