Hi all,
i have a table containing 24 columns, i would like to generate a new table by input the program gets from the user concurning of the columns he would like to see.
sound like an easy "select ? from table", but the thing is that how can the function know how to get a different number of variables, i mean, one time the user will want to see one column, and afterwards he will want to see 10 columns, is there a solution except generating 24 functions?.
i looked in all kinds of SQL tutorials and nothing came up so i came here, tnx for your help!.
Alon.public string GenerateSqlSelect(string[] columnNames){
return "SELECT "+String.Join(", ",columnNames)+" FROM MyTable";
}
|||You could use params keyword to specify that your function has a variable number of arguments.|||How user will know what are the columns from the table. Does he will write them, or select them using check boxes or some other method. I realy don't understand what are you for. Can you describe how user interface will look like, or some scenario of application work.
It is common practice that you always get all columns from table, but user can control which column want to see, for example in a grid or listview. So he will at first see all columns but it will be able to remove some of them. That configuration can be saved and used for next application start.sql
No comments:
Post a Comment