I have a string in C# which has the column names of a table as shown below
shown_itemsName = "billno,department,date,subtotal,tea,coffee";
I want to display a table in dataGridView with column names that are there in the string (shown_itemsName) but when i write sql query
cmdDataBase.CommandText = "select @shown_itemsName from employee.transaction where department = @department AND MONTH(date) = @month_ AND YEAR(date) = @year_";
cmdDataBase.Parameters.AddWithValue("@shown_itemsName", shown_itemsName);
cmdDataBase.Parameters.AddWithValue("@department", this.department.Text);
cmdDataBase.Parameters.AddWithValue("@month_", this.dateTimePicker1.Value.Month);
cmdDataBase.Parameters.AddWithValue("@year_", this.dateTimePicker1.Value.Year);
I get a table with only 1 column and 4 rows with the cell value as billno,department,date,subtotal,tea,coffee and the heading of that column also the same string. Whereas I should be getting 6 columns and 4 rows as the result with the "," separated substrings as the column names