基本信息
源码名称:C# 会员登录示例源码(access数据库)
源码大小:0.06M
文件格式:.zip
开发语言:C#
更新时间:2018-05-24
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍


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 System.Data.OleDb;
namespace Case05_5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("输入登录信息不完整,请从新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);            //提示对话框
            }
            else
            {

                string mypath = Application.StartupPath   "\\mydata.mdb";   //连接数据库的路径及数据库名
                string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="   mypath   ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据库字符串
                OleDbConnection  mycon = new OleDbConnection(constr);   //定义OleDbConnection对象实例并连接数据库
                mycon.Open();
                string mysql = "select * from person where 用户名 = '"   textBox1.Text   "' and  密码= '"   textBox2.Text   "'";                 //Sql查询语句

                OleDbDataAdapter myada = new OleDbDataAdapter(mysql, mycon);
                DataTable mydt = new DataTable();
                myada.Fill(mydt);
                int i = mydt.Rows.Count;
                if (i >= 1)
                {
                    Form2 myf = new Form2();
                    myf.Show();           //显示主界面
                    myf.label1.Text = "欢迎 "   textBox1.Text   " 登录主界面 ,其登录密码是: "   textBox2.Text;
                }
                else
                {
                    MessageBox.Show("用户名或密码不正确,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);            //提示对话框
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.textBox1.Text = "";            //清空文本框
            this.textBox2.Text = "";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();     //退出程序
        }
    }
}