gpt4 book ai didi

mysql - "Mixing of GROUP columns .. with no GROUP columns is illegal if there is no GROUP BY clause"

转载 作者:行者123 更新时间:2023-11-29 12:43:20 25 4
gpt4 key购买 nike

我正在 Visual Studio 2012 上使用 C# 开发一个软件。我使用 MySQL Connector 6.9.1 进行 MySQL 连接。我的软件在我的操作系统(Win8 x64)上运行顺利,但在 Win7 上无法运行(在 VMWare 上,我必须在 Win7 上尝试一下)

这是抛出这个异常:

MySql.Data.MySqlClient.MySqlException (0x80004005): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

这是我的代码:

      MySqlCommand komut = new MySqlCommand();
komut.Connection = baglan;
komut.CommandType = CommandType.Text;
komut.CommandText = "SELECT count(*),yetki FROM kullanicilar WHERE kadi=@kadi AND sifre=@sifre";
komut.Parameters.AddWithValue("@kadi", txtKadi.Text);
komut.Parameters.AddWithValue("@sifre", txtSifre.Text);
MySqlDataReader oku = komut.ExecuteReader();
oku.Read();
if (oku.GetInt32(0) > 0)
{

if (oku.GetString("yetki") == "0")
{
MessageBox.Show("Hesabınız aktif değil.","Hesap Deaktif",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
baglan.Close();
return;
}

RandevulariYonet randPenc = new RandevulariYonet(txtKadi.Text, this);
this.Hide();
randPenc.ShowDialog();

}
else
{
MessageBox.Show("Giriş Başarsız", "Giriş Başarısız", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

最佳答案

问题出在 SQL 语句中:

SELECT count(*),yetki 
FROM kullanicilar
WHERE kadi=@kadi AND sifre=@sifre

您使用 count(*) 和另一列,而不对其进行分组。它应该看起来像这样:

SELECT count(*),yetki 
FROM kullanicilar
WHERE kadi=@kadi AND sifre=@sifre
GROUP BY yetki

关于mysql - "Mixing of GROUP columns .. with no GROUP columns is illegal if there is no GROUP BY clause",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25803767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com