• 大小: 36KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-01
  • 语言: C#
  • 标签: C#  用户登录  

资源简介

做的很简单。但是大家可以依据里面的主要代码进行修改,那样就能基本实现你想要的效果了!

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;


namespace dl
{
    public partial class Form1 : Form
    {
        DataSet ds;
        int maxNum;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            OleDbConnectionStringBuilder connectStringBuilder = new OleDbConnectionStringBuilder();
            connectStringBuilder.DataSource = Application.StartupPath.ToString() + “\\dl.mdb“;
            connectStringBuilder.Provider = “Microsoft.Jet.OLEDB.4.0“;
            OleDbConnection myOleDbConnection = new OleDbConnection(connectStringBuilder.ConnectionString);
            myOleDbConnection.Open();
            OleDbCommand cm = new OleDbCommand(“select * from dl where name=‘“ + txtUserName.Text + “‘ and password=‘“ + txtPassWord.Text + “‘“ myOleDbConnection);

            OleDbDataReader ra=cm.ExecuteReader ();
            if (ra.HasRows)
            {
                MessageBox.Show(“登入成功!“);
            }
            else
            {
                MessageBox.Show(“用户不存在,请检测用户名和密码是否正确!“);
            }

            //OleDbDataAdapter da = new OleDbDataAdapter(cm);
            //ds = new DataSet();
            //myOleDbConnection.Open();
            //int numberOfRows = da.Fill(ds “dl“);
            //myOleDbConnection.Close();
            //maxNum = ds.Tables[“dl“].Rows.Count;
            //if (maxNum == 1)//如果数据中没有记录或有多条记录则抱错 
            //{
            //    MessageBox.Show(“登入成功!“);
            //}
            //else
            //{
            //    MessageBox.Show(“用户不存在,请检测用户名和密码是否正确!“);

            //}
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5612  2008-12-04 08:56  dl\dl\Properties\Resources.resx

     文件        249  2008-12-04 08:56  dl\dl\Properties\Settings.settings

     文件       1162  2008-12-04 08:56  dl\dl\Properties\AssemblyInfo.cs

     文件       2858  2008-12-04 08:56  dl\dl\Properties\Resources.Designer.cs

     文件       1085  2008-12-04 08:56  dl\dl\Properties\Settings.Designer.cs

     目录          0  2008-12-04 08:56  dl\dl\Properties

     文件       3211  2008-12-04 08:58  dl\dl\dl.csproj

     文件       5632  2005-11-11 22:25  dl\dl\bin\Debug\dl.vshost.exe

     文件      20480  2008-12-04 10:24  dl\dl\bin\Debug\dl.exe

     文件      19968  2008-12-04 10:24  dl\dl\bin\Debug\dl.pdb

     文件     147456  2008-12-04 08:54  dl\dl\bin\Debug\dl.mdb

     目录          0  2008-12-04 08:56  dl\dl\bin\Debug

     目录          0  2008-12-04 08:56  dl\dl\bin

     目录          0  2008-12-04 08:56  dl\dl\obj\Debug\TempPE

     文件        180  2008-12-04 09:58  dl\dl\obj\Debug\dl.Form1.resources

     文件        180  2008-12-04 08:58  dl\dl\obj\Debug\dl.Properties.Resources.resources

     文件      20480  2008-12-04 10:24  dl\dl\obj\Debug\dl.exe

     文件        842  2008-12-04 09:58  dl\dl\obj\Debug\dl.csproj.GenerateResource.Cache

     文件      19968  2008-12-04 10:24  dl\dl\obj\Debug\dl.pdb

     目录          0  2008-12-04 08:56  dl\dl\obj\Debug

     文件        233  2008-12-04 10:24  dl\dl\obj\dl.csproj.FileList.txt

     目录          0  2008-12-04 08:56  dl\dl\obj

     文件        461  2008-12-04 08:56  dl\dl\Program.cs

     文件       4057  2008-12-04 09:58  dl\dl\Form1.Designer.cs

     文件       5814  2008-12-04 09:58  dl\dl\Form1.resx

     文件       1935  2008-12-04 10:24  dl\dl\Form1.cs

     目录          0  2008-12-04 08:56  dl\dl

     文件        895  2008-12-04 08:56  dl\dl.sln

    ..A..H.     11776  2008-12-04 10:24  dl\dl.suo

     目录          0  2008-12-04 08:56  dl

............此处省略3个文件信息

评论

共有 条评论