?
Solved

VB.NET MSSQL Read column namn by query?

Posted on 2011-09-14
7
Medium Priority
?
417 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 2000 total points
ID: 36536234
select * from sys.columns
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

752 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