查询没有给出确切的结果

时间:2016-09-14 14:37:17

标签: c# mysql visual-studio select

当我在Visual Studio中编码时,我的查询没有给出正确的结果,但是当我在MySql Workbench中尝试它时,它工作正常。有人能帮助我吗?

MySqlCommand cmd = null;
DataTable dataTable = new DataTable();
MySqlConnection mycon = new MySqlConnection("datasource=localhost; port=3306;username=root;password=; database = cmb;");

string se = "SELECT date AS 'Date', COUNT(case when patienttype = 'Child' then 1 else null end) AS `No of Child`, COUNT(case when patienttype = 'Adult' then 1 else null end) AS `No of Adult` FROM cmb.stat";
cmd = new MySqlCommand(se, mycon);

mycon.Open();
using (MySqlDataAdapter da = new MySqlDataAdapter(cmd))
{
    da.Fill(dataTable);
}

dataGridView1.DataSource = dataTable;
dataGridView1.DataMember = dataTable.TableName;
mycon.Close();

VS Studio中的结果:

Result in VS Studio

MySQL Workbench中的结果:

Result in MySql Workbench

0 个答案:

没有答案