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;//引入MySql数据接口
namespace HWork3_1单词记忆学习测试系统
{
public partial class Form12 : Form
{
public Form12()
{
InitializeComponent();
}
private void Form12_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)//登录
{
string name = textBox1.Text.Trim();
string password = textBox2.Text.Trim();
//连接mysql数据库
MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder();
sb.Server = "127.0.0.1";
sb.Port = 3306;
sb.Database = "englishlearningsystem";
sb.UserID = "root";
sb.Password = "root";
sb.CharacterSet = "gb2312";
MySqlConnection con = new MySqlConnection(sb.ConnectionString);//实例化连接
con.Open();
if (radioButton1.Checked == true)//用户表
{
String query = "select * from user where uname='" + name + "' and upassword='" + password + "'";//向数据库服务器发送指令
MySqlCommand cmd = new MySqlCommand(query, con);
//执行结果赋值到dr,dr为只读
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Form1 form1 = new Form1();
form1.Show();
}
else if (name == "" || password == "")
{
MessageBox.Show("对不起
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;//引入MySql数据接口
namespace HWork3_1单词记忆学习测试系统
{
public partial class Form12 : Form
{
public Form12()
{
InitializeComponent();
}
private void Form12_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)//登录
{
string name = textBox1.Text.Trim();
string password = textBox2.Text.Trim();
//连接mysql数据库
MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder();
sb.Server = "127.0.0.1";
sb.Port = 3306;
sb.Database = "englishlearningsystem";
sb.UserID = "root";
sb.Password = "root";
sb.CharacterSet = "gb2312";
MySqlConnection con = new MySqlConnection(sb.ConnectionString);//实例化连接
con.Open();
if (radioButton1.Checked == true)//用户表
{
String query = "select * from user where uname='" + name + "' and upassword='" + password + "'";//向数据库服务器发送指令
MySqlCommand cmd = new MySqlCommand(query, con);
//执行结果赋值到dr,dr为只读
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Form1 form1 = new Form1();
form1.Show();
}
else if (name == "" || password == "")
{
MessageBox.Show("对不起