C#实现登录功能
目标:可视化的登录界面,可实现登录,注册。
C#集成开发环境:VS2019
数据库:MySQL数据库
界面最终效果图
登录界面
登录成功界面
注册界面
数据库
登录代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//登录
string userName = this.textBox1.Text;
string userPassword = this.textBox2.Text;
if (userName.Equals(""