Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

VB.NET MSSQL Read column namn by query?

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
kavvis
Asked:
kavvis
  • 4
  • 2
1 Solution
 
deightonCommented:
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
 
kavvisAuthor Commented:
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
 
Alpesh PatelAssistant ConsultantCommented:
select * from sys.columns
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
kavvisAuthor Commented:
PatelAlpesh:
I'm Not sure what you mean right now...

0
 
kavvisAuthor Commented:
I have found some info like this...

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

Is this the right way to go?
0
 
kavvisAuthor Commented:
thank I think I understand right now!
0
 
Alpesh PatelAssistant ConsultantCommented:
You can use both Infomation_schema and sys.columns
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now