Advertisement
Motoko055

Login em C#

May 16th, 2016
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11. using System.Data;
  12.  
  13.  
  14. namespace LoginAndGestao
  15. {
  16.     public partial class Form1 : Form
  17.     {
  18.  
  19.         SqlConnection conn = new SqlConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:-Users-André-Documents-login.mdb");
  20.         SqlCommand comando = new SqlCommand();
  21.         SqlDataReader dr;
  22.  
  23.         public Form1()
  24.         {
  25.             InitializeComponent();
  26.         }
  27.         private void panel1_Paint(object sender, PaintEventArgs e)
  28.         {
  29.             comando.Connection = conn;
  30.         }
  31.  
  32.         private void button2_Click(object sender, EventArgs e)
  33.         {
  34.             if (MessageBox.Show("Deseja Sair?", "Sair", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  35.             {
  36.                 Application.Exit();
  37.             }
  38.         }
  39.  
  40.         private void button1_Click(object sender, EventArgs e)
  41.         {
  42.             if (textBox1.Text != "" & textBox2.Text != "")
  43.             {
  44.                 conn.Open();
  45.                 comando.CommandText = "INSERT INTO Login(Usuario, Senha) VALUES('" + textBox1.Text + "', '" + textBox2.Text + "')";
  46.                 comando.ExecuteNonQuery();
  47.                 conn.Close();
  48.  
  49.                 textBox1.Text = "";
  50.                 textBox2.Text = "";
  51.             }
  52.         }
  53.  
  54.        
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement