Simple ADO.Net Login

ADO.NET is a large set of .NET classes that enable us to retrieve and manipulate data, and update data sources, in very many different ways. As an essential part of the .NET framework, it shares many of its features: features such as multi-language support, garbage collection, just-in-time compilation, object-oriented design, and dynamic caching, and is far more than an upgrade of previous versions of ADO. ADO.NET is set to become a core component of any data-driven .NET application or Web Service, and understanding its power will be essential to anyone wishing to utilize .NET data maintain to maximum effect.

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

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
OleDbConnection con = new OleDbConnection(@”Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\shahrooz\Desktop\login.accdb;Persist Security Info=True”);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmd = new OleDbCommand(“select * from login where username ='” + maskedTextBox1.Text + “‘”, con);
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (maskedTextBox1.Text == dr[0].ToString())
{
if (maskedTextBox2.Text == dr[1].ToString())
{
MessageBox.Show(“i Sucesss “);
}
else
{
MessageBox.Show(“Incorrect Password”, “Information”);
}
}
}
con.Close();
dr.Close();
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s