Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2007, 12:55 PM
Authorized User
 
Join Date: Sep 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying Table Column/Fields names in a listbox

Hi,

I am trying to display column/field names in a scrollable listbox (instead of its data content). Since I'm fairly new to listboxes I'm not even sure this is possible. I do however understand the concept of binding a listbox to a table to display data within that table. Is there anyway to bind to a table displaying its column/field names?

Any assistance on this matter is great appreciated.



 
Old September 25th, 2007, 11:36 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

The database technology is intrinsic to your question. (Access? Oracle? SQLServer? . . .?)
 
Old September 25th, 2007, 12:29 PM
Authorized User
 
Join Date: Sep 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Of course it is..please my apologies. The database technology is SQL Server 2000, but may change to AS/400 db2.

 
Old September 25th, 2007, 12:40 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You can get column names for X table from the [INFORMATION_SCHEMA] so your select statement might literally look like this:

SELECT
  [COLUMN_NAME]
FROM
  [INFORMATION_SCHEMA]
WHERE
  [TABLE_NAME] = 'yourtablename'

hth

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old September 25th, 2007, 03:37 PM
Authorized User
 
Join Date: Sep 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That worked just fine with a minor adjustment. Thank you very much. The select statement I used looks like this:
   SELECT COLUMN_NAME
   FROM INFORMATION_SCHEMA.COLUMNS
   WHERE (TABLE_NAME = 'salehistp')

I'm also able to bring back table names using the same methodology.

Thanks







Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic column names in crystal reports pankaj_daga Crystal Reports 3 January 19th, 2009 02:55 AM
Populate a List Box with Table Names & Table date hewstone999 Access VBA 1 February 27th, 2008 10:10 AM
Column names! Help! dirtdog22 Access VBA 6 June 1st, 2007 06:37 AM
show just the column names from a MySQL command crmpicco MySQL 5 December 7th, 2006 08:34 AM
Query for Column Names and Datatypes rstelma SQL Server 2000 3 August 23rd, 2005 02:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.