Click here to Skip to main content
15,913,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have to maintain 2 dropdownlist boxes 1 for bindtables from database and another one is bind columns of that particular dropdownlist selected table after select the column of the dropdownlistbox that will be displayed as ordered manner in gridview
i have used this but not get output:

SQL
CREATE  PROCEDURE  [Retail].[usp_Screens]                                          
                                    
 @varCommandtype varchar(100) = null ,                           

 @varTableName varchar(1000) = null,    
 @varSortBy varchar(250) = null,    
 @varSQL varchar(1000) = null    

                                      
 as   begin   
IF(@varCommandtype='SortDateByColumnName')      
 BEGIN      
 set @varSQL = 'Select * from ' + @varTableName + ' ORDER BY ' + @varSortBy   ;    
 exec @varSQL  
 --Select * from ''+ @varTableName + ORDER BY+'' + @varSortBy;  
     
   
 END    
end
Posted
Updated 23-Apr-12 0:22am
v2
Comments
Sandeep Mewara 23-Apr-12 6:18am    
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.

1 solution

SQL
Your Question is not making the thing much Clear here is the solution if you are looking the list of the Columns of the selected table into Drop downlist.


-----------------
CREATE PROCEDURE sproc_getColumns 
@varTableName varchar(1000) = null ,
@varSortBy varchar(250) = null
as begin

select COLUMN_NAME  FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=@varTableName Order By COLUMN_NAME @varSortBy 
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900