- [C#] Viết ứng dụng xem và dò kết quả xổ số kiến thiết miền nam
- [EBOOK] Chia sẽ giáo trình học lập trình C - Giáo sư Phạm Văn Ất
- [C#] Hướng dẫn viết ứng dụng theo dõi máy in bao nhiêu trang (Monitor Printer)
- [C#] Lấy thông tin cấu hình máy tính xuất ra text file winform
- [C#] Chia sẽ class Install, Uninstall, Start và Stop Services Winform
- [C#] Tìm kiếm tập tin file nhanh chóng trên Winform sử dụng thư viện FastSearchLibrary
- [C#] Giới thiệu thư viện Fluent FTP Awesome dùng để làm việc với FTP
- [C#] Sử dụng thư viện Mini Profiler Integrations ghi log thực hiện các câu lệnh SQL
- [DEVEXPRESS] Thiết kế Dropdown ButtonBarItem trên Form Ribbon
- [C#] Lưu trạng thái các control trên Winform vào Registry Windows
- [C#] Ứng dụng ví dụ Simple Observer Pattern tăng giảm số lượng trên winform
- [C#] Hướng dẫn lấy thời gian thực server time trên winform
- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
[C#] Lập trình cài đặt mật khẩu cho file Microsoft Access và tool giải mã password MDB
Xin chào các bạn, bài viết hôm nay mình sẽ tiếp tục hướng dẫn các bạn cách tạo mật khẩu bảo mật cho file database Microsoft Access (*.mdb) trong lập trình C# winform.
[C#] Tạo mật khẩu cho file Microsoft Access và Tool giải mã password
Trong lập trình kết nối cơ sở dữ liệu OleDB (Access) với C#, chúng ta muốn bảo mật database của mình lại.
Để cài đặt mật khẩu cho file Database Access, các bạn sử dụng câu lệnh sau:
ALTER DATABASE PASSWORD 'matkhaucu', 'matkhaumoi'
Giao diện demo ứng dụng cài đặt mật khẩu cho file Access.
Bài viết chỉ ứng dụng cho File Micsoft Acess có định dạng là MDB
thôi nhé.
Source code Tạo mật khẩu Database Access C#:
using System;
using System.Data.OleDb;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Linq;
namespace setaccesspass
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "MS-Access (*.mdb)|*.mdb";
if (openFileDialog1.ShowDialog() != DialogResult.OK)
{
return;
}
if (openFileDialog1.FileName.Equals(String.Empty))
{
MessageBox.Show("Please enter a file name.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
txtfilename.Text = openFileDialog1.FileName;
}
private void button2_Click(object sender, EventArgs e)
{
setpassword(txtfilename.Text, txtoldpassword.Text, txtnewpassword.Text);
}
private void setpassword(string FilePath, string OldPassword, string NewPassword)
{
try
{
if (File.Exists(FilePath))
{
string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FilePath + ";Jet OLEDB:Database Password=" + OldPassword + ";Mode=12";
string OledbConnectionString = conString;
using (OleDbConnection con = new OleDbConnection(OledbConnectionString))
{
string sql = string.Empty;
sql = string.Format("ALTER DATABASE PASSWORD [{0}] [{1}]", NewPassword, OldPassword);
OleDbCommand cmd = new OleDbCommand(sql, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Password set successfully.");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
private void Button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
Còn muốn lấy mật khẩu của file Acess MDB, các bạn có thể chạy file accesspv.exe
, mình có để trong thư mục source download.
Giao diện lấy mật khẩu file database MS Access:
Thanks for watching!