這是我的存儲過程:調用MySQL的存儲過程
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;
我需要調用下面的代碼,而不是下面的MySQL查詢(QUERY1)
C#代碼這個程序 - >
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);
}
}
在c#代碼中查詢1的位置如何調用以上MySQL過程?
@PreetSangha我怎樣才能調用MySQL過程就地MySQL查詢 – vim
可能重複[this](http://stackoverflow.com/questions/1260952/how-to-execute-a-stored-procedure-within-c -sharp-program) – jomsk1e
@ jomsk1e這個副本也沒有解釋如何調用過程的body.its只調用過程的名字。 – vim