Advertisement
beannshie

Full Code

Jul 11th, 2018
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.OleDb;
  6. using System.Data.SqlClient;
  7. using System.Drawing;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13.  
  14. namespace Insert_Test
  15. {
  16. public partial class Form1 : Form
  17. {
  18. private OleDbConnection connection = new OleDbConnection();
  19. string database = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\password.accdb";
  20.  
  21.  
  22. public Form1()
  23. {
  24. InitializeComponent();
  25. connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + database + ";Jet OLEDB:Database Password=1711223ms;";
  26. }
  27.  
  28. private void Form1_Load(object sender, EventArgs e)
  29. {
  30. MessageBox.Show("Please input your password here", "Password Request Instrucion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  31. }
  32.  
  33. private void pass_btn_Click(object sender, EventArgs e)
  34. {
  35. try
  36. {
  37. connection.Open();
  38.  
  39. OleDbCommand command = new OleDbCommand();
  40. command.Connection = connection;
  41. command.CommandText = "INSERT INTO Password ([password]) VALUES('" + password.Text + "')";
  42.  
  43. command.ExecuteNonQuery();
  44. MessageBox.Show("Success");
  45.  
  46. connection.Close();
  47. }
  48. catch (Exception ex)
  49. {
  50. MessageBox.Show(Convert.ToString(ex));
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement