Solved

VB.NET MSSQL Read column namn by query?

Posted on 2011-09-14
7
414 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
[X]
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
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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
I have a large data set and a SSIS package. How can I load this file in multi threading?
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, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

687 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