using System;
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.MySqlClient;
namespace WindowsFormsApplication1
{
public partial class login : Form
{
public login()
{
InitializeComponent();
}
static string constr = "server=localhost;User Id=root;password=;Database=ex";
MySqlConnection mycon = new MySqlConnection(constr);
MySqlCommand mycmd = new MySqlCommand();
private void ui_bt_login_Click(object sender, EventArgs e)
{
//string constr = "server=localhost;User Id=root;password=;Database=ex";
//MySqlConnection mycon = new MySqlConnection(constr);
mycon.Open();
string sql = "select * from user where Name='"+ui_text_name+"' and Password='"+ui_text_pwd +"'";
mycmd.Connection = mycon;
mycmd.CommandText = sql;
mycmd.CommandType = CommandType.Text;
MySqlDataReader dr = mycmd.ExecuteReader();//运行后这里显示给定关键字不在字典中
dr.Read();
if (dr.HasRows)
{
this.Hide();
Form1 Form1 = new Form1();
Form1.Show();
}
else
{
MessageBox.Show("登陆失败");
}
mycon.Close();
}
请问哪里错了
![图片说明](https://img-ask.csdn.net/upload/201703/20/1490017187_314223.png)