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.OleDb; namespace WindowsFormsApplication1 { public partial class frmlgn : Form { OleDbCommand cmd; public frmlgn() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { cmd = new OleDbCommand("select * from login where id='" + textBox1.Text + "'", Class1.con); OleDbDataReader dr; dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows == true) { if (dr["password"].ToString() != textBox2.Text) { MessageBox.Show("Password Not Matched!"); textBox2.Focus(); } else { MessageBox.Show("successfuly login"); this.Close(); MDIParent2 mdi=new MDIParent2(); } } else MessageBox.Show("Invalid User id"); dr.Close(); }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.OleDb; namespace WindowsFormsApplication1 { class Class1 { public static OleDbConnection con; public static void Connection() { con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= e:\db1.mdb"); con.Open(); } } }
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.OleDb; namespace WindowsFormsApplication1 { public partial class frmlgn : Form { OleDbCommand cmd = new OleDbCommand(); OleDbConnection con = new OleDbConnection(); OleDbDataReader dr; public frmlgn() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { con.ConnectionString = Class1.con; con.Open(); cmd.Parameters.Clear(); cmd.Connection = con; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from login where id='" + textBox1.Text + "'"; OleDbDataReader dr; dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows == true) { if (dr["password"].ToString() != textBox2.Text) { MessageBox.Show("Password Not Matched!"); textBox2.Focus(); } else { MessageBox.Show("successfuly login"); Form1 a = new Form1(); this.Hide(); a.Show(); } } else MessageBox.Show("Invalid User id"); dr.Close(); } and connection string Class1 As shown below using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.OleDb; namespace WindowsFormsApplication1 { class Class1 { internal static string con = (@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= d:\db1.mdb"); } }
cmd = new OleDbCommand("select * from login where id='" + textBox1.Text + "'", Class1.con);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)