作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 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/
我是一名优秀的程序员,十分优秀!