【发布时间】:2020-05-04 13:20:21
【问题描述】:
我正在使用 Visual Studio 编写程序。我在登录表单中收到错误。当我搜索互联网。我找不到任何解决方法。我使用 vb.net 时没有任何问题。我在使用 C# 时看到此错误。 为什么我看到这个错误? 我的代码:
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
MySqlConnection bag = new MySqlConnection("Allow User Variables=True;Server=localhost;Database=gamesh;Uid=root;Pwd='';");
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
bag.Open();
MySqlCommand komut = new MySqlCommand("SELECT * from kullanıcılar where clause KullanicıAdi='" + TextBox1.Text.Trim() + "' and Sifre='" + TextBox2.Text.Trim() + "'", bag);
MySqlDataReader dr = komut.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("Hoşgeldiniz");
}
else
{
MessageBox.Show("Hatalı Giriş");
}
bag.Close();
}
}
}
【问题讨论】:
标签: mysql database exception mysql-error-1064 login-script