无法在C#DGV

时间:2015-06-27 04:30:16

标签: c# mysql

我的C#应用​​程序中有2个DGV,然后我编写了我的代码。两个DGV的代码完全相同,但只有1个DGV可以显示数据。为什么? 有人可以帮忙吗?如果想看到输出,可以给我发电子邮件:candy.9639@gmail.com PS:我的声誉不足以让我在这里发布图片。

C#:

 private void LoadData()
    {
        string MyConnectionString = "Server=31.220.XX.XX;Database=XXXXX_fyp;Uid=XXXXX_eee2110;Pwd=myPW;";

        MySqlConnection connection = new MySqlConnection(MyConnectionString);
        MySqlCommand cmd = connection.CreateCommand();
        MySqlDataAdapter adap = new MySqlDataAdapter(cmd);
        connection.Open();

        cmd.CommandText = "SELECT tablenum, name, quantity FROM ordertable where tablenum = '1' & status = '1'";
        DataSet ds = new DataSet();
        adap.Fill(ds);
        kitchen1_dgv.DataSource = ds.Tables[0].DefaultView;

        cmd.CommandText = "SELECT tablenum, name, quantity FROM ordertable where tablenum = '16' & status = '1'";
        DataSet ds2 = new DataSet();
        adap.Fill(ds2);
        kitchen2_dgv.DataSource = ds2.Tables[0].DefaultView;

        if (connection.State == ConnectionState.Open)
        {
            connection.Clone();
            connection.Close();
        }
    }

0 个答案:

没有答案