473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

getting the column names of a table

hi,
how can i loop and get the field names of the columns in a dataset\s table?
I want the names of the columns (i.e. the field names) not the actual data.

TIA
Nov 21 '05 #1
2 1182
Hi,

Assuming you are using sql server, build this dataset/datatable and then
simply loop through it with a datarow for each loop:

Dim dacolumns As New SqlDataAdapter("select distinct column_name from
information_schema.columns where table_name = '" & gl_xfilename & "' order
by column_name", oconn)

Dim dscolumns As New DataSet("columns")

dacolumns.Fill(dscolumns, "columns")

Dim irow As DataRow

For Each irow In dscolumns.Tables(0).Rows

columnbox.Items.Add(irow("column_name"))

Next

HTH,

Bernie Yaeger

"steve" <noemail.@try.com> wrote in message
news:qk*******************@wagner.videotron.net...
hi,
how can i loop and get the field names of the columns in a dataset\s
table?
I want the names of the columns (i.e. the field names) not the actual
data.

TIA

Nov 21 '05 #2
Hi Steve,

Psuedo code....

For I = 0 to dataset.Tables(0).Columns.Count
MsgBox(dataset.Tables(0).Columns.Item(I).ColumnNam e
Next

"steve" <noemail.@try.com> wrote in message
news:qk*******************@wagner.videotron.net:
hi,
how can i loop and get the field names of the columns in a dataset\s
table?
I want the names of the columns (i.e. the field names) not the actual
data.

TIA


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Randell D. | last post by:
Folks, I have a table of addresses and a seperate table with contact names - All addresses tie to one or more names - I would like to keep track of the number of names 'belonging' to an address...
10
by: Colleyville Alan | last post by:
I am trying to turn a short and fat (63 columns) table into one that is tall and skinny (7 columns). Basically, I am trying to create a "reverse crosstab" using a looping structure in VBA along...
2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
4
by: Scot L. Harris | last post by:
Currently using Postgresql 7.2.4-5.80 with php 4.2.2.-8.0.8 on a redhat 8.0 system. I am writing some php scripts where I want to generate a list of the column names in a particular table that...
4
by: Sean Shanny | last post by:
To all, Running into an out of memory error on our data warehouse server. This occurs only with our data from the 'September' section of a large fact table. The exact same query running over...
2
by: Matt | last post by:
Hi, I'm sure this has been asked before, but my searches haven't come up with an example. I'm writing a generic trigger function called from different tables in plpgsql that needs to get the...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
1
by: christianlott1 | last post by:
I want to provide users with an interface to create a custom merge (all in Access, not Word). User will put in a set of brackets ("<>") in a memo field and when they click the merge button it will...
5
by: dananrg | last post by:
Is there any way to retrieve column names from a cursor using the ODBC module? Or must I, in advance, create a dictionary of column position and column names for a particular table before I can...
3
by: koti688 | last post by:
how to get the column names and the values of them in select statment. I have a packaze like this named ADB.pm package ADB; use DBI; @ISA = ('Exporter');
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.