This is my stored procedure:
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'MAX(IF(goals = ''',
goals,
''', round(value, 2), NULL)) AS ',
goals
)
) INTO @sql
FROM sgwebdb.dim_module;
SET @sql = CONCAT('SELECT alternative, ', @sql, ' FROM sgwebdb.dim_module GROUP BY
alternative');
prepare stmt from @sql;
execute stmt;
I need to call this procedure in below code instead of below MySQL query (query1)
C# code -->
protected void Page_Load(object sender, EventArgs e)
{
BindGrid();
}
private void BindGrid()
{
string query1 = "SELECT alternative as 'Alternative',max( case when goals='G1' then round( value, 2 ) end ) as 'Goal 1',max( case when goals='G2' then round( value, 2 ) end ) as 'Goal 2',max( case when goals='G3' then round( value, 2 ) end ) as 'Goal 3',max( case when goals='G4' then round( value, 2 ) end ) as 'Goal 4' from sgwebdb.dim_module group by alternative";
this.GridView1.DataSource = DataManager.DatabaseManager.GetOrCreateConnection(DataManager.DatabaseManager.ConnectionType.MySQL).GetData(query1);
GridView1.DataBind();
for (int n = 0; n < (GridView1.Rows.Count - 1); n++)
{
Textval.Text = GridView1.Rows[n].Cells[1].Text;
double gdval = Convert.ToDouble(Textval.Text);
}
}
Inplace of Query1 in c# code how can I call above MySQL procedure ?