473,587 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Columns From SP!

An ASP application needs to display DISTINCT records of all the columns
existing in a SQL Server DB table in different drop-down lists. The
column names & the no. of columns aren't known while coding. The no. of
drop-downs depend on the no. of columns i.e. if the DB table has 10
columns, there should be 10 drop-downs. This is the stored procedure I
have written to do this:

----------------------------------------
CREATE PROCEDURE GetRecords
AS
DECLARE
@ordpos int,
@colname sysname,
@sql varchar(8000)

SET @ordpos=1

WHILE @ordpos<=(SELEC T COUNT(*) FROM INFORMATION_SCH EMA.COLUMNS WHERE
TABLE_NAME='MyT able')
BEGIN
SELECT @colname=COLUMN _NAME FROM INFORMATION_SCH EMA.COLUMNS WHERE
TABLE_NAME='MyT able' AND ORDINAL_POSITIO N=@ordpos
SET @sql='SELECT DISTINCT(' + @colname + ') FROM MyTable ORDER BY ' +
@colname
EXEC(@sql)
SET @ordpos=@ordpos +1
END
----------------------------------------

As such, the above stored procedure works fine when executed in the
Query Analyzer but the problem is in populating the drop-downs in the
ASP page. Since the stored procedure generates the column names
dynamically, I don't know the column names while coding the different
drop-downs.

How do I populate the drop-downs? Note that I want the name of the
individual drop-downs to be the name of the column.

Thanks,
Arpan

Sep 29 '05 #1
0 1103

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

Similar topics

10
12724
by: VA | last post by:
I got the following function to swap table columns from somewhere on the Internet function swapColumns (table, colIndex1, colIndex2) { if (table && table.rows && table.insertBefore && colIndex1 != colIndex2) { for (var i = 0; i < table.rows.length; i++) { var row = table.rows; var cell1 = row.cells; var cell2 = row.cells;
2
2119
by: Kevin | last post by:
Hi Al Can someone tell me how to hide colums in a datagrid. I have a one datagrid that is a master and child and I would like to hide specific columns, how do I do this TI Kevin
1
840
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called...
2
6388
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
13
2478
by: scorpion53061 | last post by:
Very urgent and I am very close but need a little help to get me over the edge........ I need to write these columns to a html file with each row containing these columns (seperated by breaks). Currently this code write all columns to a single row which works but is not what the boss wants. If anyone has suggestions how you would do a...
5
2645
by: Gary Blakely | last post by:
I'm giving this post another try - it can't be too difficult for everyone.... In the program below, the web page has dataGrid1. the only thing that has been done to it at design time is to check the "Create columns automatically at runtime" checkbox - nothing else. The code below does indeed create the visual grid as expected. ...
2
1164
by: Dibs | last post by:
Hi all, short question. is there anyway of changing the order of a datatable's columns? cheers, Dibs
1
2431
by: thomasp | last post by:
Will someone tell me why with the following code: 1. The user can not resize the columns 2. The DTG column is not formatted as "dd-MMM-yy HH:mm:ss" 3. The user can modify the data in all columns Is it because on the line: .AutoGenerateColumns = True ? If so can I somehow over ride this after the code has generated the columns? ...
0
1940
by: bappelsin | last post by:
Hello, I have a problem with the datagridview. I have a view with around 25 different columns. To make life easier for the users I have implemented a popup dialog where the user can select which columns that should be displayed and in which order the columns are shown. After user has selected the visible columns and the order he presses ok....
5
2155
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can change depending how many columns are in a Table. I add a new column with this code: Private Sub Button4_Click(ByVal sender As System.Object, ByVal...
0
7918
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.