c#mysql数据库
2024-09-07 02:22:28
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 Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
MySqlConnection Conn = new MySqlConnection("Database=admin;server=localhost;User Id=root;Password="); string sql = "select * from user";
MySqlCommand Da = new MySqlCommand(sql, Conn);
Conn.Open();
//MySqlDataAdapter ad = new MySqlDataAdapter();
MySqlDataReader re = Da.ExecuteReader();
//re.Read();
//DataSet a = new DataSet();
string username1 = this.username.Text.Trim();
string password1 = this.password.Text.Trim();
//string u1=re[1].ToString();
//string p1=re[2].ToString();
if (username1 == "" || password1 == "")
{
MessageBox.Show("用户名不能为空"); }
else {
if (re.Read()) { string u1 = re[1].ToString();
string p1=re[2].ToString();
if (username1 == u1 || password1 == p1)
{ MessageBox.Show("正确");
}
else { MessageBox.Show("密码错误");
} } } }
}
}
最新文章
- myhandle
- 第十四章:降维:奇异值分解SVD
- java 入门 第二季4
- SOLID面向对象的五个设计原则,留空待学习。
- sql*loader的直接加载方式和传统加载方式的性能差异
- ToolBar、ActionBar与Menu的纠葛(以及navigationIcon、setHomeButtonEnabled、setDisplayHomeAsUpEnabled)
- Asp.Net的两种开发方式
- 已知ip地址和其子网掩码如何求网络号子网号主机号
- ext 3.2 tree 在IE10中点击事件失效的bug
- 大文件读取方法(C#)
- 为何与0xff进行与运算
- 关于文件读写IDL
- 命令行分析组件IKende.CLI
- js 数组 map方法
- 《笨方法学Python》加分题1
- redis命令大全参考手册
- 网格视图GridView的使用
- golang redis集群操作:redis-go-cluster
- centos7 搭建keepalived+Nginx+tomcat
- 【转载】Impala和Hive的区别