Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.OleDb;
- namespace WindowsFormsApplication21
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (textBox1.Text == "" || textBox2.Text == "")
- {
- label3.Text = "please plovide the field mensoined";
- label3.Visible = true;
- }
- else
- {
- try
- {
- label3.Text = "wrong uername or password";
- OleDbConnection con=new OleDbConnection();
- con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\SurajNegi Data\data.accdb";
- OleDbCommand cmd = new OleDbCommand("SELECT * from data where USERNAME=@user and PASSWORD=@pass",con);
- cmd.Parameters.AddWithValue("@user",textBox1.Text);
- cmd.Parameters.AddWithValue("@pass",textBox2.Text);
- con.Open();
- DataSet da = new DataSet();
- OleDbDataAdapter adt = new OleDbDataAdapter(cmd);
- adt.Fill(da);
- con.Close();
- int count = da.Tables[0].Rows.Count;
- if (count > 0)
- {
- MessageBox.Show("WELCOME");
- }
- else
- {
- label3.Visible = true;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("cannot open {0}", ex.ToString());
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment